~/bend-docscommunity

bolt/rules/correctness/arms.bend fails

raw source on the hub · import 0x729eecea86ea5a2cdba3a2856a313bca/bolt/rules/correctness/arms.bend as Arms

rule arms: a Nat arm no value can reach. case kn+p: matches every Nat from k up, so a later case jn+q: with j >= k, or a later case mn: with m >= k, never runs. The checker accepts it and the match quietly returns the earlier arm (nohzafk pat_bad: 0n, 1n+p, 2n+p gives f(2n) = 1; bend 2.0.16 still does). Put the narrower arms first: the literals, then the larger n+p. Succ{p} counts as 1n+p. Only a single-scrutinee match is read: a column of a multi-scrutinee match is skipped.

7 imports
import Base
import ../../src.bend as Src
import ../../finding.bend as F
import ../../../syntax/lex.bend as Lex
import ../../../syntax/tree.bend as Tree
import ../../../lazy/lazy.bend as Lazy
import ../tokens.bend as T