rsc-statement-order
one statement taken to run before another by their places in a block, as index(s) < index(t).
- Group
- Code
- Runs
- Optional: run it with
ur lint --rule rsc-statement-order - Level
- warning
- Reads
- Every file
- Fix
- None: whether the order stands for the paths through a function, the write a read sees, or the reads after a write is the author's to decide
Why
Two statements' places in a block say which is written first, not which runs first or on which paths: a branch, a loop, an early return, or a closure called later decides that, and statements in different blocks are not compared at all. Whether every path to b passes a is dominates(a, b), which ur query gives every module it reads, and ur rewrite a module that declares project attributes. Which write a read sees, and whether a value is read after it is written, are the SSA values', which only the concurrency rules' modules are given so far.
The fix, as Ur suggests it: ask dominates, or the SSA values.
For agents
Ask whether one statement runs before another with dominates, or which write a read sees from the SSA values, rather than comparing their places in a block with index.
Example
checks/Later.rscmodule checks::Later
bool readLater(Tree s, str name) = any(t <- parent(s).statements, index(t) > index(s), t == name);
$ ur lint --rule rsc-statement-order
warning[rsc-statement-order]: `s` taken to run before `t` by their places in a block
--> ./checks/Later.rsc:3:67 `index(t) > index(s)`
= hint: ask `dominates`, or the SSA values
0 clone classes and 1 `rsc-statement-order` finding in 1 file