~/bend-docscommunity

src/rules/correctness/put.bend fails

raw source on the hub · import 0xde9bb08f7de298b03207fb5797ede9a5/src/rules/correctness/put.bend as Put

rule put: a call to Map.put(: among the significant tokens, a Map.put token with a ( token right after it. Base's Map.put is an internal helper of Map.set: on a leaf it keeps the old key and replaces the value without comparing keys, so putting a new key silently overwrites another entry (bend-http c91bdf8: "b" into a map of "a" replaced "a"). Use Map.set. A file that defines Map.put itself (Base's source), a def keyword with a Map.put token right after it, is exempt.

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