def ends
import bend-lint-rules@0.2.0.0/layout/case.bend as Caseimport Base
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint
149# Whether the type the last of `nodes` writes ends in a sort: it is one, or a function type whose result does.
150def ends(nodes: List<&2, Lint.Node>) -> Bool:
151 match nodes:
152 case Con{Lint.Node{Lint.Sort{}, n, s, k, f}, Nil{}}:
153 True{}
154 case Con{Lint.Node{Lint.Forall{b, q}, n, s, kids, f}, Nil{}}:
155 ends(kids)
156 case Con{x, Nil{}}:
157 False{}
158 case Con{x, rest}:
159 ends(rest)
160 case Nil{}:
161 False{}