Tail.walk: def of bolt@1.27.0.0 Import: import bolt@1.27.0.0/src/rules/pedantic/tail.bend as Tail Lines 30-53 of bolt@1.27.0.0/src/rules/pedantic/tail.bend: https://jend.leeeet.dev/read.txt?path=bolt@1.27.0.0/src/rules/pedantic/tail.bend&start_line=30&end_line=53 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 # the self-calls not in tail position; skip: the chain is a bare self-call def walk(nn: Tree.Node, +name: String, +path: String, skip: Bool) -> List<&2, F.Finding>: match nn: case Tree.NCons{Tree.Leaf{Lex.Tok{k, +t, +l, +c}}, Tree.NCons{Tree.Group{Lex.Tok{_, +o, _, _}, +kids, _}, rest}}: +call = String.eq(o, "(") +me = Bool.and(Bool.and(call, String.eq(t, name)), Bool.not(skip)) +inside = walk(kids, name, path, False{}) +more = List.concat(&2, F.Finding, [ Bool.pick(List<&2, F.Finding>, Bool.and(call, String.eq(t, "Bool.pick")), [], inside), walk(rest, name, path, False{})]) Bool.pick(List<&2, F.Finding>, me, F.Finding{path, l, c, U32.from_nat(String.length(name)), "tail", "This call to " ++ name ++ " is not a tail call, so a long list or string overflows the stack on the JS lane; carry an accumulator."} <> more, more) case Tree.NCons{Tree.Group{open, kids, close}, rest}: List.concat(&2, F.Finding, [walk(kids, name, path, False{}), walk(rest, name, path, False{})]) case Tree.NCons{Tree.Stmt{kind, +kids, body}, rest}: List.concat(&2, F.Finding, [walk(kids, name, path, bare(kids, name)), walk(body, name, path, False{}), walk(rest, name, path, False{})]) case Tree.NCons{h, rest}: walk(rest, name, path, False{}) case other: Nil{} Uses (15): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.not https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.pick https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List.concat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.append https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.eq https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.length https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.from_nat https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/finding.bend&name=Finding https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/pedantic/tail.bend&name=bare https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/lex.bend&name=Tok https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/tree.bend&name=Node