def verdict
bend-lint-rules@0.2.0.0 · language/decreasing_call.bend:165
import bend-lint-rules@0.2.0.0/language/decreasing_call.bend as DecreasingCall
import Base
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint
165
166def verdict(
167 params: List<&2, Param>,
168 args: List<&2, Lint.Node>,
169 told: Maybe<&2, Verdict>,
170 +smaller: List<&2, Smaller>,
171 +lets: List<&2, U32>,
172 +at: Nat
173) -> Verdict:
174 match params args told:
175 case _ _ Some{v}:
176 v
177 case Con{Param{b, True{}, n}, ps} Con{arg, rest} None{}:
178 verdict(ps, rest, None{}, smaller, lets, 1n+at)
179 case Con{Param{+b, False{}, +n}, ps} Con{Lint.Node{Lint.Variable{+a}, x, s, k, f}, rest} None{}:
180 verdict(
181 ps,
182 rest,
183 step(
184 U32.is_eq(a, b),
185 is_smaller(smaller, False{}, b, a),
186 List.contains(~U32, ~U32.is_eq, lets, a),
187 at,
188 n
189 ),
190 smaller,
191 lets,
192 1n+at
193 )
194 case Con{Param{b, False{}, n}, ps} Con{Lint.Node{Lint.Application{}, x, s, k, f}, rest} None{}:
195 Fails{at, n}
196 case Nil{} Nil{} None{}:
197 Unchanged{}
198 case _ _ None{}:
199 Unknown{}