def fold_names
bolt@1.27.0.0 · src/rules/pedantic/rewalk.bend:586
import bolt@1.27.0.0/src/rules/pedantic/rewalk.bend as Rewalk
import Base
import bolt@1.27.0.0/src/syntax/lex.bend as Lex
import bolt@1.27.0.0/src/syntax/tree.bend as Tree
586
587def fold_names(nn: Tree.Node, st: Lhs) -> Lhs:
588 match nn:
589 case Tree.NCons{Tree.Leaf{Lex.Tok{Lex.TName{}, +t, l, c}}, rest}:
590 Lhs{seen, extra, field, nm} = st
591 fold_names(rest, add_seen(seen, extra, True{}, nm, t))
592 case Tree.NCons{Tree.Group{open, +kids, close}, rest}:
593 fold_names(rest, fold_names(kids, st))
594 case Tree.NCons{h, rest}:
595 fold_names(rest, st)
596 case other:
597 st