Skip to content

defer inside do is broken #20491

@tobyink

Description

@tobyink

Description
do { defer { ... } } doesn't run the deferred block at the end of the do block, but at the end of the block enclosing the do block.

Steps to Reproduce
This says "second" then "first".

use v5.36;
use experimental 'defer';

do {
	defer { say "first" };
};

say "second";

Expected behavior
This says "first" then "second". (Which is expected!)

use v5.36;
use experimental 'defer';

{
	defer { say "first" };
};

say "second";

(Note that the same bug is seen in Syntax::Keyword::Defer!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions