~/bend-docscommunity

src/rules/suspicious/rewalk.bend fails

raw source on the hub · import 0xde9bb08f7de298b03207fb5797ede9a5/src/rules/suspicious/rewalk.bend as Rewalk

rule rewalk: one straight piece of a def calls the same walk twice on the same argument, and one result is used only for a single value (a get of one index, one field, or a let whose name is only read that way) while the other result is kept whole. Take the value from that other result. The same argument is the same text with no let of any name it uses (= or <-, taking effect at the end of the let) between the two calls. A different case arm is a different path, and two narrow reads are left alone. A walk is a def of this file that loops, or a Base walk (List.map and the like). Laws and proofs do not run (a def with no type at all fills a law: it is a proof). This is not twice, which is duplicate literals in a list pattern.

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