def loops
bend-lint-rules@0.2.0.0 · performance/eager_branch.bend:257
import bend-lint-rules@0.2.0.0/performance/eager_branch.bend as EagerBranch
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
import bend-lint-api@0.2.0.0/shared/names.bend as Names
import bend-lint-api@0.2.0.0/shared/sets.bend as Sets
257
258def loops(
259 names: List<&2, String>,
260 +defs: Map<&2, Maybe<&2, Lint.Def>>,
261 +unflat: Set(),
262 out: List<&2, String>
263) -> List<&2, String>:
264 match names:
265 case Nil{}:
266 out
267 case Con{+t, rest}:
268 loops(
269 rest,
270 defs,
271 unflat,
272 Lists.push(
273 String,
274 Lists.when(String, Sets.has(unflat, t) && calls_itself(Names.find(Lint.Def, defs, t)), t),
275 out
276 )
277 )