def is_live_inside

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

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

62# Whether the nodes under `node`, which is live if `live`, are: a body is; a type is not (an equality, a function or
63# pair type, a type's arguments). An annotation's type is not either: see `scan`.
64def is_live_inside(+node: Lint.Node, live: Bool) -> Bool:
65  match node:
66    case Lint.Node{Lint.Body{}, n, s, k, f}:
67      True{}
68    case Lint.Node{Lint.Equality{}, n, s, k, f}:
69      False{}
70    case Lint.Node{Lint.Forall{b, q}, n, s, k, f}:
71      False{}
72    case Lint.Node{Lint.TypeApplication{t}, n, s, k, f}:
73      False{}
74    case Lint.Node{Lint.Application{}, n, s, kids, f}:
75      live && Bool.not(Lint.is_pair(kids))
76    case _:
77      live

Uses (6)

Used by (1)