def Once.of

bend-lint-rules@0.2.0.0 · language/reused_binder.bend:34

import bend-lint-rules@0.2.0.0/language/reused_binder.bend as ReusedBinder
import Base
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint

34# The binders a definition declares that can be used once, as their syntax says for sure: a parameter written without
35# `+` (unless one is `bare`: its quantity is its law's), and a let's name written without `+`. A pattern's field is left
36# out: its quantity also comes from its scrutinee's type (a field of a `List<&2, A>` is reusable), which the rule cannot
37# see.
38def Once.of(+bare: Bool, +path: List<&2, Lint.Above>, +node: Lint.Node) -> List<&2, Once>:
39  match path node:
40    case _ Lint.Node{Lint.Parameter{b, Lint.Once{}}, name, s, k, f}:
41      Bool.pick(List<&2, Once>, bare, [], [Once{b, name}])
42    case Con{
43      Lint.Above{Lint.Node{Lint.Destructure{q}, pn, ps, pk, pf}, at},
44      up
45    } Lint.Node{Lint.PatternVariable{b, Lint.Once{}}, name, s, k, f}:
46      [Once{b, name}]
47    case _ _:
48      []

Uses (8)

Used by (1)