src/rules/pedantic/tail.bend checks
raw source on the hub · import 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/rules/pedantic/tail.bend as Tail
rule tail: a def whose first live parameter is a List or a String calls
itself where the call is not the whole statement: h <> go(t),
(1 + go(t) : U32), +rest = go(t). The test is on that parameter's type
alone, never on whether the self-call shrinks it: a def that recurses on
a later Nat is reported too, and one whose list comes second is not. Each
such call holds a frame until the rest of the input is done, and the JS lane
overflows its stack at a few thousand to ~64K elements (bend-http on a 48KB
header, agora at ~4,900 entries); native is fine. Carry an accumulator and
make the self-call the whole statement (reverse once at the end if order
matters). Idiomatic code does this on purpose, so the rule is noisy: off
unless asked. Everything inside a Bool.pick(..) is skipped, whether or
not pick reports it; laws and proofs are exempt, and a def with no type
at all fills a law, so it is a proof.
7 imports
import Base import ../../src.bend as Src import ../../finding.bend as F import ../../syntax/lex.bend as Lex import ../../syntax/tree.bend as Tree import ../../lazy/lazy.bend as Lazy import ../calls.bend as Calls
Definitions
def bare source · line 23 · raw
@kids:0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/tree.Node -> @+name:String -> Bool
is a statement's chain exactly a call of the name, name(..)?
def walk source · line 31 · raw
@nn:0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/tree.Node -> @+name:String -> @+path:String -> @skip:Bool -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>
the self-calls not in tail position; skip: the chain is a bare self-call
def check.go source · line 55 · raw
@ds:List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/rules/calls.Def> -> @+path:String -> @acc:List<&2, List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>> -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>
def check source · line 65 · raw
@ss:0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/src.Src -> List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/finding.Finding>
the rule