~/bend-docscommunity

language/reused_binder.bend fails

raw source on the hub · import bend-lint-rules@0.1.0.0/language/reused_binder.bend as Reused_binder

language/reused_binder: a binder written without + that live code uses twice on one path, so the check fails ("consumed more than once"). Heuristics: it checks only the binders whose quantity the syntax gives for sure: a parameter or a let's name written without +, which can be used once on each path. It leaves out a pattern's field, whose quantity also comes from its scrutinee's type, and a law's bare parameter. Two uses are on one path unless they are in different cases of one match. Both values of a call count, so Bool.pick(T, c, x, x) uses x twice. Uses in types are dead and do not count. A binder that a match takes apart is skipped: in a case, it stands for the matched constructor. Bend's checker stops at its first error; this rule reports every such binder at once.

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