~/bend-docscommunity

src/rules/pedantic/tail.bend fails

raw source on the hub · import 0xde9bb08f7de298b03207fb5797ede9a5/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