From: Rafael Garcia-Suarez Date: Thu, 12 Sep 2002 19:33:06 +0000 (+0000) Subject: Fix a syntax incompatibility introduced by the // operator. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7ce6e6b9b330bcb2a1d155869572dcbf97a67971;p=p5sagit%2Fp5-mst-13.2.git Fix a syntax incompatibility introduced by the // operator. (Note that C is still a syntax error, it wasn't with perl 5.8.0.) p4raw-id: //depot/perl@17900 --- diff --git a/t/op/dor.t b/t/op/dor.t index 2f918fc..979419b 100644 --- a/t/op/dor.t +++ b/t/op/dor.t @@ -10,7 +10,7 @@ BEGIN { package main; require './test.pl'; -plan( tests => 25 ); +plan( tests => 30 ); my($x); @@ -59,3 +59,16 @@ for (qw(getc pos readline readlink undef umask <> <$foo> -f)) { eval "sub { $_ // 0 }"; is($@, '', "$_ // ... compiles"); } + +# Test for some ambiguous syntaxes + +eval q# sub f ($) { } f $x / 2; #; +is( $@, '' ); +eval q# sub f ($):lvalue { $y } f $x /= 2; #; +is( $@, '' ); +eval q# sub f ($) { } f $x /2; #; +like( $@, qr/^Search pattern not terminated/ ); +eval q# sub { print $fh / 2 } #; +is( $@, '' ); +eval q# sub { print $fh /2 } #; +like( $@, qr/^Search pattern not terminated/ ); diff --git a/toke.c b/toke.c index 0e1e65a..fa0f1ac 100644 --- a/toke.c +++ b/toke.c @@ -3554,14 +3554,9 @@ Perl_yylex(pTHX) PL_expect = XTERM; /* e.g. print $fh .3 */ else if (strchr("?-+", *s) && !isSPACE(s[1]) && s[1] != '=') PL_expect = XTERM; /* e.g. print $fh -1 */ - else if (*s == '/') { - if(s[1] == '/') { - PL_expect=XOPERATOR; - } - else { - PL_expect=XTERM; - } - } + else if (*s == '/' && !isSPACE(s[1]) && s[1] != '=' && s[1] != '/') + PL_expect = XTERM; /* e.g. print $fh /.../ + XXX except DORDOR operator */ else if (*s == '<' && s[1] == '<' && !isSPACE(s[2]) && s[2] != '=') PL_expect = XTERM; /* print $fh <<"EOF" */ }