def is_dead

bend-lint-rules@0.2.0.0 · performance/dead_accumulator.bend:77

import bend-lint-rules@0.2.0.0/performance/dead_accumulator.bend as DeadAccumulator
import Base
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint

77# Whether a parameter of quantity `q` that is used as `kinds` says is a dead accumulator: it is there at run time, it
78# is only passed to the loop's own calls, and grows in one at least.
79def is_dead(q: Lint.Quantity, +kinds: List<&2, U32>) -> Bool:
80  match q:
81    case Lint.Erased{}:
82      False{}
83    case Lint.Template{}:
84      False{}
85    case _:
86      Bool.not(
87        List.contains(~U32, ~U32.is_eq, kinds, 0)
88      )
89        && List.contains(~U32, ~U32.is_eq, kinds, 2)

Uses (8)

Used by (1)