Skip to content

Fix re/pat.t test failures: empty pattern reuse, /o modifier caching, pos() reset#279

Merged
fglock merged 2 commits intomasterfrom
fix-pat-t-tests
Mar 6, 2026
Merged

Fix re/pat.t test failures: empty pattern reuse, /o modifier caching, pos() reset#279
fglock merged 2 commits intomasterfrom
fix-pat-t-tests

Conversation

@fglock
Copy link
Owner

@fglock fglock commented Mar 6, 2026

Summary

  • Fix pos() reset when string is modified with .= operator
  • Implement empty pattern // reuse (uses last successful pattern)
  • Add /o modifier caching per callsite with new QUOTE_REGEX_O opcode

Details

pos() reset (test 237)

  • Added RuntimePosLvalue.invalidatePos() method
  • Both interpreter and JVM backends now reset pos() to undef after .=

Empty pattern reuse (tests 198-201, 203)

  • Added empty pattern handling to matchRegexDirect - reuses lastSuccessfulPattern
  • Perl behavior: // matches using the last successfully compiled regex pattern

/o modifier caching (test 207)

  • Implemented /o modifier caching per callsite
  • Added new QUOTE_REGEX_O opcode with callsite ID parameter
  • Both interpreter and JVM backends support proper /o caching
  • Each regex with /o compiles the pattern only once at first execution

Test Results

  • re/pat.t: 239/239 tests pass (was 233/239)
  • op/bop.t: 488/522 tests pass (same as master - no regression)
  • Unit tests: All pass

Generated with Devin

fglock and others added 2 commits March 6, 2026 18:38
Implement RuntimePosLvalue.invalidatePos() to set pos() to undef when
a string is modified. When $_ .= "" is executed, the pos() value
should be reset because the string content has changed.

This fixes test 237 in re/pat.t.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
- Add empty pattern handling to matchRegexDirect (reuses lastSuccessfulPattern)
- Implement /o modifier caching per callsite with QUOTE_REGEX_O opcode
- Add callsite ID allocation in bytecode compiler and JVM emitter
- Updates both interpreter and JVM backends

This fixes tests 198-201, 203, and 207 in re/pat.t, bringing pass count to 239/239.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
@fglock fglock merged commit 7f0f510 into master Mar 6, 2026
2 checks passed
@fglock fglock deleted the fix-pat-t-tests branch March 6, 2026 18:12
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