Skip to content

fix(parser): compound assignment to a constant, and the **= operator - #21

Merged
tannevaled merged 1 commit into
mainfrom
fix/const-opassign
Aug 30, 2026
Merged

tannevaled merged 1 commit into
mainfrom
fix/const-opassign

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Two more gaps that made whole ruby/spec files fail to load:

  • C OP= x / A::B OP= x — compound assignment to a (possibly scope-resolved) constant was rejected. Arithmetic and &&= desugar to C = C OP x (as the ivar/gvar/cvar forms do); ||= is guarded behind defined? — (defined?(C) && C) || (C = x) — so C ||= x defines an undefined constant rather than raising NameError, matching MRI (verified end-to-end against MRI 4.0.6).
  • **= — power-assignment was lexed as ** then = (a parse error) for every target (x **= 2, @i **= 2, C **= 2, chained a **= b **= 2); it is now a single OP= token. x ** 2 stays the power operator.

go vet, the full suite and the 100% merged-coverage gate stay green.

Two more gaps that made ruby/spec files fail to load:

  * `C OP= x` / `A::B OP= x` — compound assignment to a (possibly
    scope-resolved) constant was rejected. Arithmetic and `&&=` desugar
    to `C = C OP x`, as the ivar/gvar/cvar forms do; `||=` is guarded
    behind `defined?` — `(defined?(C) && C) || (C = x)` — so it DEFINES
    an undefined constant rather than raising NameError, matching MRI.
  * `**=` — power-assignment lexed as `**` then `=` (a parse error); it
    is now a single OP= token for every target, right-associative.

go vet, the full suite and the 100% merged-coverage gate stay green.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit ff45713 into main Aug 30, 2026
11 checks passed
@tannevaled
tannevaled deleted the fix/const-opassign branch August 30, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant