Skip to content

Conversation

@fglock
Copy link
Owner

@fglock fglock commented Jan 6, 2026

Fixes control flow propagation for last SKIP through function calls in scalar context.

Problem

Test #2 in skip_control_flow.t was failing:

sub inner2 { last SKIP }
sub outer2 { my $x = inner2(); return $x; }
SKIP: { my $r = outer2(); }

The last SKIP in inner2() wasn't exiting the SKIP block because the control flow marker wasn't being checked after outer2() returned.

Solution

Added registry check in EmitBlock.java after each statement in simple labeled blocks (≤3 statements without loop constructs). The check:

  • Calls RuntimeControlFlowRegistry.hasMarker()
  • If marker present, calls checkLoopAndGetAction(labelName)
  • Jumps to nextLabel if action != 0

Limited to simple blocks to avoid ASM VerifyError in complex code.

Results

  • ✅ skip_control_flow.t: all 3 tests pass
  • ✅ make: BUILD SUCCESSFUL
  • ✅ Baseline maintained: 66683/66880 tests passing in perl5_t/t/uni/variables.t
  • ✅ No ASM errors

Add registry check after each statement in simple labeled blocks (≤3 statements)
to handle non-local control flow like 'last SKIP' through function calls.

The check:
- Only applies to labeled blocks without loop constructs
- Checks RuntimeControlFlowRegistry after each statement
- Jumps to nextLabel if matching control flow detected
- Limited to simple blocks to avoid ASM VerifyError

Results:
- skip_control_flow.t: all 3 tests pass ✓
- make: BUILD SUCCESSFUL ✓
- Baseline maintained: 66683/66880 tests passing in perl5_t/t/uni/variables.t ✓
@fglock fglock force-pushed the fix-control-flow-scalar-context-v2 branch from d8dbee8 to 5a3baef Compare January 6, 2026 08:44
@fglock fglock merged commit 97346c2 into master Jan 6, 2026
2 checks passed
@fglock fglock deleted the fix-control-flow-scalar-context-v2 branch January 6, 2026 08:55
fglock added a commit that referenced this pull request Jan 6, 2026
Now that the control flow fix is merged (PR #121), we can remove the
TestMoreHelper workaround that was transforming skip() calls at parse time.

Changes:
- Removed TestMoreHelper.java
- Removed TestMoreHelper calls from StatementParser and StatementResolver
- Updated Test::More.pm skip() to use 'last SKIP' directly
- Removed skip_internal() from Test::More.pm exports
- Cleaned up test.pl.patch to remove skip_internal workaround

Results:
- skip_control_flow.t: all 3 tests pass ✓
- Baseline maintained: 66683/66880 ✓
fglock added a commit that referenced this pull request Jan 6, 2026
Now that the control flow fix is merged (PR #121), we can remove the
TestMoreHelper workaround that was transforming skip() calls at parse time.

Changes:
- Removed TestMoreHelper.java
- Removed TestMoreHelper calls from StatementParser and StatementResolver
- Updated Test::More.pm skip() to use 'last SKIP' directly
- Removed skip_internal() from Test::More.pm exports
- Cleaned up test.pl.patch to remove skip_internal workaround

Results:
- skip_control_flow.t: all 3 tests pass ✓
- Baseline maintained: 66683/66880 ✓
fglock added a commit that referenced this pull request Jan 6, 2026
Now that the control flow fix is merged (PR #121), we can remove the
TestMoreHelper workaround that was transforming skip() calls at parse time.

Changes:
- Removed TestMoreHelper.java
- Removed TestMoreHelper calls from StatementParser and StatementResolver
- Updated Test::More.pm skip() to use 'last SKIP' directly
- Removed skip_internal() from Test::More.pm exports
- Cleaned up test.pl.patch to remove skip_internal workaround

Results:
- skip_control_flow.t: all 3 tests pass ✓
- Baseline maintained: 66683/66880 ✓
fglock added a commit that referenced this pull request Jan 6, 2026
Now that the control flow fix is merged (PR #121), we can remove the
TestMoreHelper workaround that was transforming skip() calls at parse time.

Changes:
- Removed TestMoreHelper.java
- Removed TestMoreHelper calls from StatementParser and StatementResolver
- Updated Test::More.pm skip() to use 'last SKIP' directly
- Removed skip_internal() from Test::More.pm exports
- Cleaned up test.pl.patch to remove skip_internal workaround

Results:
- skip_control_flow.t: all 3 tests pass ✓
- Baseline maintained: 66683/66880 ✓
fglock added a commit that referenced this pull request Jan 6, 2026
Now that the control flow fix is merged (PR #121), we can remove the
TestMoreHelper workaround that was transforming skip() calls at parse time.

Changes:
- Removed TestMoreHelper.java
- Removed TestMoreHelper calls from StatementParser and StatementResolver
- Updated Test::More.pm skip() to use 'last SKIP' directly
- Removed skip_internal() from Test::More.pm exports
- Cleaned up test.pl.patch to remove skip_internal workaround

Results:
- skip_control_flow.t: all 3 tests pass ✓
- Baseline maintained: 66683/66880 ✓
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.

2 participants