Skip to content

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

Open
@wolfsage

Description

@wolfsage

This works:

use strict;
use warnings;

use experimental qw(defer);

sub foo {
  defer {
    goto ham;

    ham:
    print "ham\n";
  }
}

foo();

ham

This doesn't:

use strict;
use warnings;

use experimental qw(defer);

sub foo {
  defer {
    goto ham;

    ham:
    print "ham\n";
  }

  print "uh oh\n";
}

foo();
uhoh
Can't "goto" out of a defer block at works.pl line 8.

It seems anything after the defer block in the same scope breaks the goto detection...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions