Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent return from being optimised away by newer (>= 5.19.7) Perls. #1

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 16 additions & 2 deletions Want.pm
Expand Up @@ -169,15 +169,29 @@ sub rreturn (@) {
croak "Can't rreturn in lvalue context";
}
double_return();
return wantarray ? @_ : $_[$#_];

# Extra scope needed to work with perl-5.19.7 or greater.
# Prevents the return being optimised out, which is needed
# since it's actually going to be used a stack level above
# this sub.
{
return wantarray ? @_ : $_[$#_];
}
}

sub lnoreturn () {
if (!want_lvalue(1) || !want_assign(1)) {
croak "Can't lnoreturn except in ASSIGN context";
}
double_return();
return disarm_temp(my $undef);

# Extra scope needed to work with perl-5.19.7 or greater.
# Prevents the return being optimised out, which is needed
# since it's actually going to be used a stack level above
# this sub.
{
return disarm_temp(my $undef);
}
}

# Some naughty people were relying on these internal methods.
Expand Down