Skip to content

Fix pos() reset after study() to clear /g zero-length guard#176

Merged
fglock merged 2 commits intomasterfrom
fix-test-more-imports
Feb 7, 2026
Merged

Fix pos() reset after study() to clear /g zero-length guard#176
fglock merged 2 commits intomasterfrom
fix-test-more-imports

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Feb 7, 2026

This PR includes two commits:

  • bbcbdfd Fix BEGIN blocks to access outer lexical variables in eval STRING
  • f7a73de Fix pos() reset to clear zero-length /g guard

Context

re/regexp.t regressed by 3 subtests (1097, 1110, 1111) involving study $subject; pos($subject)=0; followed by /g lookahead matches.

Fix

Clear the zero-length match guard state when assigning to pos($str), so an explicit pos reset behaves like perl5 and doesn't get blocked by the repeated zero-length match protection.

Verification

  • Ran make
  • Re-ran perl5_t/t/re/regexp.t: the 3 regressed subtests are now passing (not-ok count drops 427 -> 424).

fglock and others added 2 commits February 6, 2026 22:27
In perl5, BEGIN blocks inside eval STRING can access outer lexical
variables with their runtime values. For example:
    my @imports = qw(md5 md5_hex);
    eval q{ use Digest::MD5 @imports };  # BEGIN sees @imports

Previously, BEGIN blocks would see empty variables because they execute
during parsing, before the eval class is instantiated with runtime values.

Solution:
1. Modified evalStringHelper() to accept runtime values array
2. Store runtime values in ThreadLocal during eval STRING parsing
3. In SpecialBlockParser, alias special globals to runtime objects
4. Global variable keys don't include sigil (use "pkg::arr" not "pkg::@arr")
5. Added backwards-compatible evalStringHelper(code, evalTag) overload

This fixes Test::More use_ok() pattern which relies on this behavior.

Note: control_flow.t test 11 is currently failing with "Can't find label"
error. This needs further investigation as it may be a separate issue.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fglock fglock merged commit 26f35b0 into master Feb 7, 2026
2 checks passed
@fglock fglock deleted the fix-test-more-imports branch February 7, 2026 13:50
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