Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix return 1, :a(2)
Though return is implemented as a function call, we may not promote pairs to
named arguments, because we cannot demote them afterwards.

Fixes RT #75118
  • Loading branch information
niner committed Sep 19, 2015
1 parent 0f699bb commit 0d40e00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Perl6/Actions.nqp
Expand Up @@ -5198,7 +5198,7 @@ Compilation unit '$file' contained the following violations:
if nqp::istype($_, QAST::Op) && istype($_.returns, $Pair) {
my $name := compile_time_value_str($_[1], 'LHS of pair', $/);
%named_counts{$name} := +%named_counts{$name} + 1;
unless $*IN_DECL eq 'use' || $*IN_DECL eq 'no' || $*IN_DECL eq 'import' {
unless $*IN_DECL eq 'use' || $*IN_DECL eq 'no' || $*IN_DECL eq 'import' || $*IN_RETURN {
$_[2].named($name);
}
}
Expand All @@ -5207,7 +5207,7 @@ Compilation unit '$file' contained the following violations:
# Make result.
for @args {
if nqp::istype($_, QAST::Op) && istype($_.returns, $Pair) {
my $name := $_[2].named();
my $name := compile_time_value_str($_[1], 'LHS of pair', $/);
if %named_counts{$name} == 1 {
$past.push($_[2]);
$_[2].annotate('before_promotion', $_);
Expand Down
4 changes: 4 additions & 0 deletions src/Perl6/Grammar.nqp
Expand Up @@ -1048,6 +1048,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
:my $*IN_META := ''; # parsing a metaoperator like [..]
:my $*IN_REDUCE := 0; # attempting to parse an [op] construct
:my $*IN_DECL; # what declaration we're in
:my $*IN_RETURN := 0; # are we in a return?
:my $*HAS_SELF := ''; # is 'self' available? (for $.foo style calls)
:my $*begin_compunit := 1; # whether we're at start of a compilation unit
:my $*DECLARAND; # the current thingy we're declaring, and subject of traits
Expand Down Expand Up @@ -3140,7 +3141,9 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
<longname>
:my $*longname;
:my $pos;
:my $*IN_RETURN;
{ $*longname := $*W.dissect_longname($<longname>); $pos := $/.CURSOR.pos }
{ $*IN_RETURN := $<longname>.Str eq 'return'; }
[
|| <?{ nqp::eqat($<longname>.Str, '::', 0) || $*W.is_name($*longname.components()) }>
<.unsp>?
Expand Down Expand Up @@ -3669,6 +3672,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
method EXPR(str $preclim = '') {
# Override this so we can set $*LEFTSIGIL.
my $*LEFTSIGIL := '';
my $*IN_RETURN := 0;
nqp::findmethod(HLL::Grammar, 'EXPR')(self, $preclim, :noinfix($preclim eq 'y='));
}

Expand Down

0 comments on commit 0d40e00

Please sign in to comment.