def binds

bolt@1.27.0.0 · src/rules/pedantic/rewalk.bend:521

import bolt@1.27.0.0/src/rules/pedantic/rewalk.bend as Rewalk
import Base
import bolt@1.27.0.0/src/syntax/tree.bend as Tree

521# the lets of one straight piece; a case arm is not part of it
522def binds(nn: Tree.Node, +acc: List<&2, Bind>) -> List<&2, Bind>:
523  match nn:
524    case Tree.NCons{Tree.Stmt{Tree.SCase{}, kids, body}, rest}:
525      binds(rest, acc)
526    case Tree.NCons{Tree.Stmt{Tree.SLet{}, +kids, +body}, rest}:
527      +here = bind_at(lhs_names(kids, []), last_pos(Tree.leaves.go(body, Tree.leaves.go(kids, []))), acc)
528      binds(rest, binds(body, here))
529    case Tree.NCons{Tree.Stmt{kind, kids, +body}, rest}:
530      binds(rest, binds(body, acc))
531    case Tree.NCons{h, rest}:
532      binds(rest, acc)
533    case other:
534      acc

Uses (8)

Used by (1)