def is_built

bend-lint-rules@0.2.0.0 · performance/template_value_field.bend:113

import bend-lint-rules@0.2.0.0/performance/template_value_field.bend as TemplateValueField
import Base
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint
import bend-lint-api@0.2.0.0/shared/lists.bend as Lists

113# Whether a node below `path` is computed when a record of functions is built: under no lambda, and in a construction
114# with a lambda among its fields (`found`, once one is).
115def is_built(path: List<&2, Lint.Above>, found: Bool) -> Bool:
116  match path:
117    case Nil{}:
118      found
119    case Con{Lint.Above{Lint.Node{Lint.Lambda{b, q}, n, s, k, f}, at}, rest}:
120      False{}
121    case Con{Lint.Above{Lint.Node{Lint.Construction{t}, n, s, kids, f}, at}, rest}:
122      is_built(rest, Bool.or(found, Lists.any(~Lint.Node, ~is_lambda, kids)))
123    case Con{a, rest}:
124      is_built(rest, found)

Uses (8)

Used by (1)