Summary
Found while dogfooding mutest v0.6.0 (e6eca1b) against a real-world Go codebase (commit eb6320af). The clamp idiom produces a provably unkillable mutant:
// private/pkg/thread/thread.go:43 — reported SURVIVED
if parallelism < 1 {
parallelism = 1
}
Mutating < to <= is equivalent for every input:
x < 1: both clamp to 1
x == 1: original does nothing, mutant assigns 1 — same result
x > 1: neither fires
No test can ever kill this mutant, so it is guaranteed noise in every run, which conflicts with the project goal that every surviving mutant should represent a real test gap.
Proposal
Skip the boundary mutation when an if statement matches the clamp shape:
- Cond is
x OP C with OP in <, <=, >, >= (either operand order)
- Body is exactly one assignment
x = C where x and C are syntactically identical to the condition operands
Since the comparison mutator only swaps strict/non-strict operators, matching this shape can drop the mutation point entirely, same as the existing len(x) > 0 / cap(x) > 0 skips documented in "Skipped Mutations".
Notes
Variants worth covering: if C > x { x = C } (swapped operands) and max-clamps if x > C { x = C }. Patterns where the assigned value differs from the compared constant (e.g. if x < 0 { x = 1 }) are NOT equivalent and must stay mutated.
Summary
Found while dogfooding mutest v0.6.0 (e6eca1b) against a real-world Go codebase (commit eb6320af). The clamp idiom produces a provably unkillable mutant:
Mutating
<to<=is equivalent for every input:x < 1: both clamp to 1x == 1: original does nothing, mutant assigns 1 — same resultx > 1: neither firesNo test can ever kill this mutant, so it is guaranteed noise in every run, which conflicts with the project goal that every surviving mutant should represent a real test gap.
Proposal
Skip the boundary mutation when an
ifstatement matches the clamp shape:x OP Cwith OP in<,<=,>,>=(either operand order)x = CwherexandCare syntactically identical to the condition operandsSince the comparison mutator only swaps strict/non-strict operators, matching this shape can drop the mutation point entirely, same as the existing
len(x) > 0/cap(x) > 0skips documented in "Skipped Mutations".Notes
Variants worth covering:
if C > x { x = C }(swapped operands) and max-clampsif x > C { x = C }. Patterns where the assigned value differs from the compared constant (e.g.if x < 0 { x = 1 }) are NOT equivalent and must stay mutated.