def walk

bolt@1.27.0.0 · src/rules/correctness/twice.bend:57

import bolt@1.27.0.0/src/rules/correctness/twice.bend as Twice
import Base
import bolt@1.27.0.0/src/finding.bend as F
import bolt@1.27.0.0/src/syntax/tree.bend as Tree
import bolt@1.27.0.0/src/rules/tokens.bend as T

57# every case statement under a recursive def, at any depth
58def walk(nn: Tree.Node, +path: String) -> List<&2, F.Finding>:
59  match nn:
60    case Tree.NCons{Tree.Stmt{Tree.SCase{}, kids, body}, rest}:
61      List.concat(&2, F.Finding, [arm(T.pattern(kids), path), walk(body, path), walk(rest, path)])
62    case Tree.NCons{Tree.Stmt{kind, kids, body}, rest}:
63      List.append(&2, F.Finding, walk(body, path), walk(rest, path))
64    case Tree.NCons{h, rest}:
65      walk(rest, path)
66    case other:
67      Nil{}

Uses (9)

Used by (1)