diff options
author | Ian Goodacre <Ian.Goodacre@xtra.co.nz> | 2009-03-14 19:04:12 +1300 |
---|---|---|
committer | Vincent Pit <perl@profvince.com> | 2009-03-14 12:56:02 +0100 |
commit | df3467db16fc4437950db94f0d3ad7ff8b2c9e46 (patch) | |
tree | f64144f82a655b2e386ca7edd0f3febc9142c889 | |
parent | 43eb98159eec9ba37935203e5bf9f3a4199380c5 (diff) | |
download | perl-df3467db16fc4437950db94f0d3ad7ff8b2c9e46.tar.gz |
Return OPERATOR('[') for '[' without falling through to case '~', avoiding misinterpreting "[~" as an OP_SMARTMATCH.
-rwxr-xr-x | t/base/lex.t | 10 | ||||
-rw-r--r-- | toke.c | 5 |
2 files changed, 13 insertions, 2 deletions
diff --git a/t/base/lex.t b/t/base/lex.t index f45e56cdf7..9892df5061 100755 --- a/t/base/lex.t +++ b/t/base/lex.t @@ -1,6 +1,6 @@ #!./perl -print "1..56\n"; +print "1..57\n"; $x = 'x'; @@ -267,3 +267,11 @@ foo::::::bar; eval "\$x =\xE2foo"; if ($@ =~ /Unrecognized character \\xE2 in column 5/) { print "ok $test\n"; } else { print "not ok $test\n"; } $test++; + +# Is "[~" scanned correctly? +eval ' + my @a; + my $x = $a[~1] +'; +print "not " if($@); +print "ok 57\n"; @@ -4287,7 +4287,10 @@ Perl_yylex(pTHX) BOop(OP_BIT_XOR); case '[': PL_lex_brackets++; - /* FALL THROUGH */ + { + const char tmp = *s++; + OPERATOR(tmp); + } case '~': if (s[1] == '~' && (PL_expect == XOPERATOR || PL_expect == XTERMORDORDOR)) |