This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Break s//3}->{3/e
authorFather Chrysostomos <sprout@cpan.org>
Thu, 30 Aug 2012 23:09:58 +0000 (16:09 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 31 Aug 2012 01:18:12 +0000 (18:18 -0700)
This should never have worked:

%_=(_,"Just another ");
$_="Perl hacker,\n";
s//_}->{_/e;print

t/base/lex.t
toke.c

index 590f219..1201436 100644 (file)
@@ -1,6 +1,6 @@
 #!./perl
 
-print "1..71\n";
+print "1..72\n";
 
 $x = 'x';
 
@@ -354,3 +354,7 @@ s//"#" . <<END/e;
 foo
 END
 print "ok 71 - s//'#' . <<END/e\n";
+
+eval "s//3}->{3/e";
+print "not " unless $@;
+print "ok 72 - s//3}->{3/e\n";
diff --git a/toke.c b/toke.c
index 175deb4..933503b 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -5932,7 +5932,10 @@ Perl_yylex(pTHX)
 #endif
                    return yylex();     /* ignore fake brackets */
                }
-               if (*s == '-' && s[1] == '>')
+               if (PL_lex_inwhat == OP_SUBST && PL_lex_repl
+                && SvEVALED(PL_lex_repl))
+                   PL_lex_state = LEX_INTERPEND;
+               else if (*s == '-' && s[1] == '>')
                    PL_lex_state = LEX_INTERPENDMAYBE;
                else if (*s != '[' && *s != '{')
                    PL_lex_state = LEX_INTERPEND;