rsc-binding-scan
what a name is bound to, found by scanning the blocks around it for lets.
- Group
- Code
- Runs
- Optional: run it with
ur lint --rule rsc-binding-scan - Level
- warning
- Reads
- Every file
- Fix
- None: a module over syntax is given no SSA values yet
Why
The lets written before a node in the blocks around it are not what its names read: a later let shadows an earlier one, an assignment rebinds a name without one, and if let, a match arm, a closure's parameters, and a loop bind names that no let statement does. Which write a read sees is what the SSA values say, which only the concurrency rules' modules are given so far.
The fix, as Ur suggests it: ask the SSA values which write the name reads.
For agents
Ask which write a name reads from the SSA values, rather than scanning the statements of the blocks around it for lets.
Example
checks/Bound.rscmodule checks::Bound
list[str] bound(Tree n) = [unparse(s.pattern) | a <- ancestors(n), label(a) == "statements",
s <- parent(a).statements, s is Let, index(s) < index(a)];
$ ur lint --rule rsc-binding-scan
warning[rsc-binding-scan]: what `a` reads, found by scanning its block's `let`s
--> ./checks/Bound.rsc:4:3 `s <- parent(a).statements`
= hint: ask the SSA values which write the name reads
0 clone classes and 1 `rsc-binding-scan` finding in 1 file