def branch

bend-lint-rules@0.2.0.0 · performance/loop_invariant_call.bend:185

import bend-lint-rules@0.2.0.0/performance/loop_invariant_call.bend as LoopInvariantCall
import Base
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint

185# The branch a node below `path` is in: the innermost case above it, or the definition's body (the last of `path`).
186def branch(path: List<&2, Lint.Above>, last: Maybe<&2, Lint.Node>) -> Maybe<&2, Lint.Node>:
187  match path:
188    case Nil{}:
189      last
190    case Con{Lint.Above{Lint.Node{Lint.Case{}, n, s, k, f}, at}, rest}:
191      Some{Lint.Node{Lint.Case{}, n, s, k, f}}
192    case Con{Lint.Above{p, at}, rest}:
193      branch(rest, Some{p})

Uses (5)

Used by (2)