Skip to content

Add blku_defer to the context block union and use it in pp_goto - #24825

Open
richardleach wants to merge 2 commits into
Perl:bleadfrom
richardleach:goto_within_defer_19240
Open

richardleach wants to merge 2 commits into
Perl:bleadfrom
richardleach:goto_within_defer_19240

Conversation

@richardleach

Copy link
Copy Markdown
Contributor

This enables goto within a defer {} block when the block is not the final item within its enclosing scope.

This is intended to fix: #19240 - where this worked:

sub foo {
  defer {
    goto ham;
    ham:
    print "ham\n";
  }
}
foo();

But this did not:

sub foo {
  defer {
    goto ham;
    ham:
    print "ham\n";
  }
  print "uh oh\n";
}
foo();

Note: I'm not particularly familiar with how pp_goto walks the optree, so this could do with some good scrutiny.


  • This set of changes requires a perldelta entry, and it is included.

This enables `goto` within a `defer {}` block when the block is not the
final item within its enclosing scope.

This is intended to fix GH Perl#19240, where this worked:

    sub foo {
      defer {
        goto ham;
        ham:
        print "ham\n";
      }
    }
    foo();

But this did not:

    sub foo {
      defer {
        goto ham;
        ham:
        print "ham\n";
      }
      print "uh oh\n";
    }
    foo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

goto within defer block doesn't work correctly if there is code after the defer

1 participant