def kind
bend-lint-rules@0.2.0.0 · performance/dead_accumulator.bend:34
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
34
35
36def kind(path: List<&2, Lint.Above>, target: String, at: U32, grown: Bool) -> U32:
37 match path:
38 case Con{Lint.Above{Lint.Node{Lint.Construction{t}, n, s, k, f}, a}, rest}:
39 kind(rest, target, at, True{})
40 case Con{Lint.Above{Lint.Node{Lint.Annotation{}, n, s, k, f}, a}, rest}:
41 kind(rest, target, at, grown)
42 case Con{
43 Lint.Above{
44 Lint.Node{
45 Lint.Application{},
46 n,
47 s,
48 Con{Lint.Node{Lint.Reference{t}, rn, rs, rk, rf}, args},
49 f
50 },
51 a
52 },
53 rest
54 }:
55 Bool.pick(
56 U32,
57 String.eq(t, target) && U32.is_eq(a, (at + 1: U32)),
58 Bool.pick(U32, grown, 2, 1),
59 0
60 )
61 case _:
62 0