Fix a bug with ->@ inside "@{...}"
authorFather Chrysostomos <sprout@cpan.org>
Mon, 16 Sep 2013 19:49:12 +0000 (12:49 -0700)
committerRicardo Signes <rjbs@cpan.org>
Sat, 5 Oct 2013 18:20:10 +0000 (14:20 -0400)
When encountering ->@[ or ->@{, we should only record that we are
going to need a POSTJOIN at the top level of interpolation, not
inside any brackets.  Otherwise the ->@[ can interfere with an outer
"@{...}", causing syntax errors.

t/op/postfixderef.t
toke.c

index 41d35ef..96dcf0f 100644 (file)
@@ -16,7 +16,7 @@ BEGIN {
 
 use strict qw(refs subs);
 
-plan(118);
+plan(121);
 
 {
     no warnings qw 'deprecated syntax';
@@ -367,4 +367,7 @@ is "$_->@{foo}", "foo->7 8 9", '->@{ does not interpolate without feature';
     is "foo$_->@*bar", "foo7 8 9bar", '->@* interpolated w/other stuff';
     is "foo$_->@[0,1]bar", "foo7 8bar", '->@[ interpolated w/other stuff';
     is "foo$_->@{foo}bar", "foooofbar", '->@{ interpolated w/other stuff';
+    is "@{[foo->@*]}", "7 8 9", '->@* inside "@{...}"';
+    is "@{[foo->@[0,1]]}", "7 8", '->@[ inside "@{...}"';
+    is "@{[foo->@{foo}]}", "oof", '->@{ inside "@{...}"';
 }
diff --git a/toke.c b/toke.c
index 5d3fdce..f9977d2 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -2186,7 +2186,9 @@ S_postderef(pTHX_ char const funny, char const next)
        PL_bufptr+=2;
     }
     else {
-       if ('@' == funny) PL_lex_dojoin = 2;
+       if ('@' == funny && PL_lex_state == LEX_INTERPNORMAL
+        && !PL_lex_brackets)
+           PL_lex_dojoin = 2;
        PL_expect = XOPERATOR;
        PL_bufptr++;
     }