Skip to content

Remove skip() workarounds - non-local last SKIP now works#162

Merged
fglock merged 1 commit intomasterfrom
remove-skip-workarounds
Feb 4, 2026
Merged

Remove skip() workarounds - non-local last SKIP now works#162
fglock merged 1 commit intomasterfrom
remove-skip-workarounds

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Feb 4, 2026

Summary

With block-level dispatcher sharing (#161), non-local control flow now works correctly. The skip() function can use last SKIP directly without workarounds.

Changes

Test/More.pm

  • Removed skip_internal() workaround function
  • Implemented proper skip() that uses last SKIP
  • Removed skip_internal from exports

TestMoreHelper.java

  • Removed all skip() call rewriting logic
  • Simplified to stub method with comment explaining workaround is no longer needed
  • Removed ~100 lines of complex AST traversal and rewriting code

test.pl.patch

  • Updated patch to remove skip_internal() addition
  • Perl 5 test suite now uses native skip() implementation

How It Works Now

Before (with workarounds):

# In Test/More.pm
sub skip_internal {
    # Print skip messages but don't use last SKIP
}

# TestMoreHelper.java rewrites:
skip("reason", 2)
# Into:
(skip_internal("reason", 2) || 1) && last SKIP

After (clean implementation):

# In Test/More.pm
sub skip {
    my ($name, $count) = @_;
    for (1..$count) {
        print "ok $Test_Count # skip $name\n";
        $Test_Count++;
    }
    last SKIP;  # Non-local control flow - exits SKIP block in caller
}

# No rewriting needed - just works!

Testing

Verified non-local last SKIP works correctly:

sub inner_last {
    last SKIP;  # Exits SKIP block in caller
}

SKIP: {
    inner_last();  # Flow exits SKIP block here
    print "This never prints\n";
}
print "After SKIP block\n";  # Execution continues here

All 2012 unit tests pass (100%)

Impact

  • Code cleanup: Removes ~100 lines of workaround code
  • Simpler maintenance: No special skip() handling needed
  • Better semantics: Uses standard Perl control flow
  • Proves optimization works: Non-local control flow now reliable enough to remove workarounds

This cleanup demonstrates that the block-level dispatcher optimization (#161) provides robust, production-ready non-local control flow support.

🤖 Generated with Claude Code

With block-level dispatcher sharing (PR #161), non-local control flow
now works correctly. The skip() function can use 'last SKIP' directly
without workarounds.

Changes:
- Test/More.pm: Replaced skip_internal() with proper skip() that uses last SKIP
- TestMoreHelper.java: Removed skip() call rewriting logic
- test.pl.patch: Removed skip_internal() workaround from Perl 5 tests

Testing:
- All 2012 unit tests pass (100%)
- Perl 5 tests work correctly with native skip() implementation
- Non-local last SKIP exits SKIP block immediately from subroutine

This cleanup removes ~100 lines of workaround code that is no longer needed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@fglock fglock merged commit b3e06c8 into master Feb 4, 2026
4 checks passed
@fglock fglock deleted the remove-skip-workarounds branch February 4, 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