def walk

bolt@1.27.0.0 · src/rules/suspicious/thunk.bend:147

import bolt@1.27.0.0/src/rules/suspicious/thunk.bend as Thunk
import Base
import bolt@1.27.0.0/src/finding.bend as F
import bolt@1.27.0.0/src/syntax/lex.bend as Lex
import bolt@1.27.0.0/src/syntax/tree.bend as Tree

147# every thunk of a self-call under the node, at any depth; lone: the node is
148# the rest of the kids of a call given exactly one lambda
149def walk(nn: Tree.Node, +lone: Bool, +name: String, +path: String) -> List<&2, F.Finding>:
150  match nn:
151    case Tree.NCons{+h, +rest}:
152      +here = site(h, rest, name, path)
153      List.concat(&2, F.Finding, [Bool.pick(List<&2, F.Finding>, lone, here, []),
154        walk(h, False{}, name, path), walk(rest, lone, name, path)])
155    case Tree.Group{Lex.Tok{_k, +o, _l, _c}, +kids, _cl}:
156      walk(kids, only(o, kids), name, path)
157    case Tree.Stmt{_k, kids, body}:
158      List.concat(&2, F.Finding, [walk(kids, False{}, name, path), walk(body, False{}, name, path)])
159    case _other:
160      Nil{}

Uses (10)

Used by (1)