Skip to content

feat(lexer): preserve the /o "interpolate once" regexp flag - #10

Merged
tannevaled merged 1 commit into
mainfrom
feat/preserve-regexp-once-flag
Jul 3, 2026
Merged

feat(lexer): preserve the /o "interpolate once" regexp flag#10
tannevaled merged 1 commit into
mainfrom
feat/preserve-regexp-once-flag

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Summary

The lexer collected only i/m/x from a regexp literal's trailing flags and silently dropped o (the "interpolate once" flag). Downstream VMs need /o to implement Ruby's semantics — compile an interpolated literal a single time and reuse that object even as the interpolated values change.

This preserves o in Flags at both scan sites (/…/ and %r{…}). Encoding flags (n/u/e/s) stay consumed-but-unrecorded, unchanged.

Tests

  • /a#{x}b/io → Flags io
  • %r{a#{x}b}mo → Flags mo
  • /x/n → Flags `` (encoding flag still dropped)

100% coverage gate green locally.

🤖 Generated with Claude Code

The lexer collected only i/m/x from a regexp literal's trailing flags and
silently dropped o (and the encoding flags). Downstream VMs need /o to
implement Ruby's "interpolate once" semantics — compile an interpolated
literal a single time and reuse that object — so preserve o in Flags at both
the /…/ and %r{…} scan sites. Encoding flags (n/u/e/s) stay consumed-but-
unrecorded, unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 5ae1294 into main Jul 3, 2026
9 checks passed
@tannevaled
tannevaled deleted the feat/preserve-regexp-once-flag branch July 3, 2026 10:33
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