src/rules/suspicious/unit.bend fails
raw source on the hub · import 0xde9bb08f7de298b03207fb5797ede9a5/src/rules/suspicious/unit.bend as MUnit
rule unit: a multiply or divide by the literal one (1, 1n, 1.0) on a
step that actually recurses. * and / inside (e : T) are T.mul and
T.div; bare, they are Nat. Either form, and a direct Nat.mul /
U32.mul / F32.mul or .div, does nothing when an operand is one
(/ only when the divisor is). Drop the operation. Any other factor or
divisor is left alone, and so is a base case or a def that does not call
itself. A base case is a case arm that does not call the def; the arms are
judged per case only, so a Bool.pick branch beside a self-call is still
the recursive step, and so is a lambda body inside it (a Lazy.stop
thunk or a List.map callback runs on the step). One finding per
operation, on the literal: Nat.mul(1n, 1n) is one. Laws and proofs do not
run (a def with no type at all fills a law: it is a proof).
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 ../calls.bend as Calls import ../../lazy/lazy.bend as Lazy
The reader could not load this file (at 0xde9bb08f7de298b03207fb5797ede9a5/src/config.bend:32). What bend.ts says:
Error:
- expected : a fresh name (duplicate declaration: Set)
- observed : 'Set'
Location:
31 | # a name (a group's or a rule's) at a level
32>| type Set is Data:
| ^^^
33 | Set{name: String, level: Level}