~/bend-docscommunity

bolt/rules/pedantic/tail.bend fails

raw source on the hub · import 0x729eecea86ea5a2cdba3a2856a313bca/bolt/rules/pedantic/tail.bend as Tail

rule tail: a def that walks a list or a string (its first live parameter, the one a self-call shrinks) calls itself where the call is not the whole statement: h <> go(t), (1 + go(t) : U32), +rest = go(t). 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. Self-calls inside a Bool.pick are left to the pick rule; laws and proofs are exempt.

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