performance/dead_accumulator.bend fails
raw source on the hub · import bend-lint-rules@0.1.0.0/performance/dead_accumulator.bend as Dead_accumulator
performance/dead_accumulator: a parameter of a loop that only grows and is never read: each use of it is
an argument of the loop's call of itself, at its own place, with something added to it (inside a
constructor, such as x <> acc), and the loop never matches it, returns it, or gives it to another
call. It is built on every step and freed at the end.
Heuristics: measured on bend-ml's BPE encode (bend-ml-bpe-tokenizer, as llama.bend uses it): its
done keeps the rules applied so far, for its proofs, and encode drops it; a 48,900-entry list built
and freed for each word was half of the time to tokenize 19 KB of text (26.1 s, against 11.5 s with
-done), with the same ids and the same proofs. A parameter that the loop passes unchanged is not
reported: it grows nothing. A use in a type or a proof does not count, as it does not run: the fix,
an erased parameter (-acc), keeps it there. Only the loop's own calls are read; a call of the loop
through another definition, or through a template, is not.
3 imports
import Base import bend-lint-api@0.1.0.0/linter/lint.bend as Lint import bend-lint-api@0.1.0.0/shared/lists.bend as Lists
The reader could not load this file (at 0x2b0a0dcada30f71a8eb4ec2e148b9279/linter/lint.bend:522). What bend.ts says:
Error:
- expected : a fresh constructor name (duplicate declaration: Text)
- observed : 'Text'
Location:
521 | Flag{on: Bool}
522>| Text{text: String}
| ^^^^
523 |