New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error parsing "[~" #9682
Comments
From @ig3Created by ian@alula.localperl -e '$array[~0xFFFFFFFE]' produces syntax error at -e line 1, near "0xFFFFFFFE]" Perl Info
|
From @ig3The attached patch fixes the problem (apologies for the name) but I With this patch and default configuration on linux (CentOS 5.2) the All tests successful. |
From @ig30001-Return-OPERATOR-for-without-falling-through.patchFrom 7fa3894b37ebedd573cb0d33cffdf50bf63d1588 Mon Sep 17 00:00:00 2001
From: Ian Goodacre <Ian.Goodacre@xtra.co.nz>
Date: Sat, 14 Mar 2009 19:04:12 +1300
Subject: [PATCH] Return OPERATOR('[') for '[' without falling through to case '~',
avoiding misinterpreting "[~" as an OP_SMARTMATCH.
---
toke.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/toke.c b/toke.c
index 3c3e0ad..8f5795a 100644
--- a/toke.c
+++ b/toke.c
@@ -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))
--
1.6.1
|
From @ig3FWIW, here are a couple of patches that add a new test to t/base/lex.t Regards, |
From @ig3FWIW, here are a couple of patches that add a new test to t/base/lex.t Regards, |
From @ig30002-New-test-for-correct-scanning-of.patchFrom a0e5ec1395c9ae9e9e648053f6c0e9509ec75e51 Mon Sep 17 00:00:00 2001
From: Ian Goodacre <Ian.Goodacre@xtra.co.nz>
Date: Sat, 14 Mar 2009 22:12:25 +1300
Subject: [PATCH 2/3] New test for correct scanning of "[~"
---
t/base/lex.t | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/t/base/lex.t b/t/base/lex.t
index f45e56c..1edcf01 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";
--
1.6.1
|
From @ig30003-Corrected-test-for-scan-of.patchFrom f384e88df46dfc474f629a29d39bacf0641676ae Mon Sep 17 00:00:00 2001
From: Ian Goodacre <Ian.Goodacre@xtra.co.nz>
Date: Sat, 14 Mar 2009 22:30:56 +1300
Subject: [PATCH 3/3] Corrected test for scan of "[~"
---
t/base/lex.t | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/t/base/lex.t b/t/base/lex.t
index 1edcf01..9892df5 100755
--- a/t/base/lex.t
+++ b/t/base/lex.t
@@ -269,9 +269,9 @@ if ($@ =~ /Unrecognized character \\xE2 in column 5/) { print "ok $test\n"; } el
$test++;
# Is "[~" scanned correctly?
-eval {
+eval '
my @a;
my $x = $a[~1]
-};
+';
print "not " if($@);
print "ok 57\n";
--
1.6.1
|
From bitcard@profvince.comThis is indeed a 5.10 regression introduced with smart maching in |
The RT System itself - Status changed from 'new' to 'open' |
From @ig3Vincent Pit via RT wrote:
It occurred to me that the test I wrote wasn't very good. I think the Inline Patchdiff --git a/t/base/lex.t b/t/base/lex.t
index f45e56c..1b8045b 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,8 @@ foo::::::bar;
eval "\$x =\xE2foo";
if ($@ =~ /Unrecognized character \\xE2 in column 5/) { print "ok
Inline Patchdiff --git a/toke.c b/toke.c
index 3c3e0ad..8f5795a 100644
--- a/toke.c
+++ b/toke.c
@@ -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)) |
@rgs - Status changed from 'open' to 'resolved' |
From @rgs2009/3/14 Ian Goodacre <Ian.Goodacre@xtra.co.nz>:
Thanks, I adjusted the test accordingly. (f50fa36) So squash a series of commits, just rebase your changes on the current |
Migrated from rt.perl.org#63854 (status was 'resolved')
Searchable as RT63854$
The text was updated successfully, but these errors were encountered: