Typographical Error
Detects common typos in Solidity code including =+ instead of +=, =- instead of -=, and similar operator transpositions.
Typographical Error
Overview
The typographical error detector identifies bytecode patterns that likely result from common Solidity typos. The most impactful is =+ vs +=: x =+ 1 assigns positive 1 to x (unary plus) instead of incrementing x. Similar transpositions include =- (assignment of negation vs. subtraction).
Detection Methodology
Analyzes arithmetic patterns in the HIR for assignment operations that overwrite rather than accumulate, where the context (variable naming, loop position) suggests accumulation was intended.
Examples
Sample Sigvex Output
{
"detector_id": "typographical-error",
"severity": "low",
"confidence": 0.60,
"description": "Assignment at offset 0x52 overwrites storage slot 3 with a small constant value in a context suggesting accumulation (loop body). Possible =+ instead of += typo.",
"location": { "function": "accumulate()", "offset": 82 }
}
Related Detectors
- Incorrect Exponent — XOR vs exponentiation
- Incorrect Comparison — wrong operators