State above multitest
a top-level var above @!multitest that each test writes
var acc = 0
@!multitest
let x: Int = read()
acc += x
print(acc)@!multitest
var acc = 0
let x: Int = read()
acc += x
print(acc)Why
A var declared above @!multitest is shared by every test case, and a test that writes it (acc += x, best = v) leaves its value for the next one: the first test passes and the later ones read stale state. Declare the variable below @!multitest, where each test gets a fresh one. A counter stepped by a constant (k += 1, for Case #k) is meant to carry over and is not flagged.
The practice it serves
Code that is wrong or almost certainly a bug. Denied by cpl lint. Family: T. Multitest and state.
Not flagged
A near miss: close to the pattern, but not it.
var k = 0
@!multitest
let x: Int = read()
k += 1
print(k, x)Turn it off
For one block, wrap it in with lint(state_above_multitest: allow):. For a project, add state_above_multitest = "allow" under [lints] in cp.toml.
Generated from spec/lints/state_above_multitest, the same record the linter is built from.