734417
From d546938a7c8b111c463b733910db885b24724b42 Mon Sep 17 00:00:00 2001
734417
From: Father Chrysostomos <sprout@cpan.org>
734417
Date: Thu, 20 Sep 2012 06:24:25 -0700
734417
Subject: [PATCH] require 1 << 2
734417
MIME-Version: 1.0
734417
Content-Type: text/plain; charset=UTF-8
734417
Content-Transfer-Encoding: 8bit
734417
734417
Port to 5.16.1:
734417
734417
commit c31f6d3b869d78bbd101e694fd3b384b47a77f6d
734417
Author: Father Chrysostomos <sprout@cpan.org>
734417
Date:   Thu Sep 20 06:24:25 2012 -0700
734417
734417
    [perl #105924] require 1 << 2
734417
734417
Setting PL_expect after force_next has no effect, as force_next
734417
(called by force_version and force_word) picks up the current value of
734417
PL_expect and arranges for it to be reset thereto after the forced
734417
token is force-fed to the parser.
734417
734417
The KEY_require case should be setting PL_expect to XTERM (as it
734417
already does) when there is no forced token (version or bareword),
734417
because we expect a term after ‘require’, but to XOPERATOR when
734417
there is a forced token, because we expect an operator after that
734417
forced token.
734417
734417
Since the PL_expect assignment has no effect after force_next, we can
734417
set it to XOPERATOR before calling potentially calling force_next, and
734417
then to XTERM afterwards.
734417
734417
Loop exits had the same bug, so this fixes them all.
734417
---
734417
 t/base/lex.t | 10 +++++++++-
734417
 toke.c       |  6 ++++++
734417
 2 files changed, 15 insertions(+), 1 deletion(-)
734417
734417
diff --git a/t/base/lex.t b/t/base/lex.t
734417
index ce16ef1..c2a6cc3 100644
734417
--- a/t/base/lex.t
734417
+++ b/t/base/lex.t
734417
@@ -1,6 +1,6 @@
734417
 #!./perl
734417
 
734417
-print "1..57\n";
734417
+print "1..63\n";
734417
 
734417
 $x = 'x';
734417
 
734417
@@ -273,3 +273,11 @@ $test++;
734417
 @a = (1,2,3);
734417
 print "not " unless($a[~~2] == 3);
734417
 print "ok 57\n";
734417
+
734417
+$test = 58;
734417
+for(qw< require goto last next redo dump >) {
734417
+    eval "sub { $_ foo << 2 }";
734417
+    print "not " if $@;
734417
+    print "ok ", $test++, " - [perl #105924] $_ WORD << ...\n";
734417
+    print "# $@" if $@;
734417
+}
734417
diff --git a/toke.c b/toke.c
734417
index 1d18550..aa2c3b6 100644
734417
--- a/toke.c
734417
+++ b/toke.c
734417
@@ -7344,6 +7344,7 @@ Perl_yylex(pTHX)
734417
 	    UNI(OP_DBMCLOSE);
734417
 
734417
 	case KEY_dump:
734417
+	    PL_expect = XOPERATOR;
734417
 	    s = force_word(s,WORD,TRUE,FALSE,FALSE);
734417
 	    LOOPX(OP_DUMP);
734417
 
734417
@@ -7476,6 +7477,7 @@ Perl_yylex(pTHX)
734417
 	    LOP(OP_GREPSTART, XREF);
734417
 
734417
 	case KEY_goto:
734417
+	    PL_expect = XOPERATOR;
734417
 	    s = force_word(s,WORD,TRUE,FALSE,FALSE);
734417
 	    LOOPX(OP_GOTO);
734417
 
734417
@@ -7598,6 +7600,7 @@ Perl_yylex(pTHX)
734417
 	    LOP(OP_KILL,XTERM);
734417
 
734417
 	case KEY_last:
734417
+	    PL_expect = XOPERATOR;
734417
 	    s = force_word(s,WORD,TRUE,FALSE,FALSE);
734417
 	    LOOPX(OP_LAST);
734417
 	
734417
@@ -7695,6 +7698,7 @@ Perl_yylex(pTHX)
734417
 	    OPERATOR(MY);
734417
 
734417
 	case KEY_next:
734417
+	    PL_expect = XOPERATOR;
734417
 	    s = force_word(s,WORD,TRUE,FALSE,FALSE);
734417
 	    LOOPX(OP_NEXT);
734417
 
734417
@@ -7880,6 +7884,7 @@ Perl_yylex(pTHX)
734417
 
734417
 	case KEY_require:
734417
 	    s = SKIPSPACE1(s);
734417
+	    PL_expect = XOPERATOR;
734417
 	    if (isDIGIT(*s)) {
734417
 		s = force_version(s, FALSE);
734417
 	    }
734417
@@ -7911,6 +7916,7 @@ Perl_yylex(pTHX)
734417
 	    UNI(OP_RESET);
734417
 
734417
 	case KEY_redo:
734417
+	    PL_expect = XOPERATOR;
734417
 	    s = force_word(s,WORD,TRUE,FALSE,FALSE);
734417
 	    LOOPX(OP_REDO);
734417
 
734417
-- 
734417
1.7.11.4
734417