Skip to content

Commit 6a4fd29

Browse files
committed
fix: reject a compound assignment whose target is an optional
`x += 3` on an `Int?` holding 5 answered 0, and nothing reported anything. A compound assignment reads its target, applies an operator and writes it back, so an optional target has to be unwrapped first. The check ran two acceptances before it looked at the operator: one that accepts a value an optional target can be built from, and one for collection literals. Both are a plain assignment's question, and taking either skipped the numeric check entirely, so the operator was emitted against the shell's address. The reported symptom was a segfault on a none-valued target. The quieter and worse one is the case above, where a held value reads back as zero. Those two acceptances now apply to `=` alone, which leaves every compound form reaching the numeric check and reporting E217 against the optional. Unwrapping and rewrapping instead would be a language decision rather than a fix, and it is not one this change should make on its own. ## what was tested An invalid-corpus case pins the rejection for a held value and for none. A golden covers what must keep working: compound assignment on integers and floats, and plain assignment into an optional, which is a different question and still allowed. Regressions 430/430 on both compilers, colocated std tests 114/114, pithgen 150 seeds clean, the leak gate flat, the invalid corpus 70/70, both bootstrap seed checks, formatting clean, seed regenerated.
1 parent 724945b commit 6a4fd29

6 files changed

Lines changed: 6465 additions & 6409 deletions

File tree

0 commit comments

Comments
 (0)