From: Adrian M. Enache Date: Thu, 13 Feb 2003 04:52:21 +0000 (+0200) Subject: Re: [perl #20716] scope error with brackets X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7df0d0422c26edcc954b82bd79e461b99b3c4092;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #20716] scope error with brackets Message-ID: <20030213025221.GA1215@ratsnest.hole> (better version of change #18687) p4raw-link: @18687 on //depot/perl: 437fd2104756c25dedf68c6e31cd29ecbf0e2569 p4raw-id: //depot/perl@18753 --- diff --git a/t/comp/parser.t b/t/comp/parser.t index 88f933c..ad1c5b8 100644 --- a/t/comp/parser.t +++ b/t/comp/parser.t @@ -9,7 +9,7 @@ BEGIN { } require "./test.pl"; -plan( tests => 15 ); +plan( tests => 20 ); eval '%@x=0;'; like( $@, qr/^Can't modify hash dereference in repeat \(x\)/, '%@x=0' ); @@ -68,9 +68,23 @@ eval { is( $@, '', 'PL_lex_brackstack' ); { - undef $a; - undef @b; - my $a="a"; is("${a}{", "a{", "scope error #20716"); - my $a="a"; is("${a}[", "a[", "scope error #20716"); - my @b=("b"); is("@{b}{", "b{", "scope error #20716"); + # tests for bug #20716 + undef $a; + undef @b; + my $a="A"; + is("${a}{", "A{", "interpolation, qq//"); + is("${a}[", "A[", "interpolation, qq//"); + my @b=("B"); + is("@{b}{", "B{", "interpolation, qq//"); + is(qr/${a}{/, '(?-xism:A{)', "interpolation, qr//"); + my $c = "A{"; + $c =~ /${a}{/; + is($&, 'A{', "interpolation, m//"); + $c =~ s/${a}{/foo/; + is($c, 'foo', "interpolation, s/...//"); + $c =~ s/foo/${a}{/; + is($c, 'A{', "interpolation, s//.../"); + is(<<"${a}{", "A{ A[ B{\n", "interpolation, here doc"); +${a}{ ${a}[ @{b}{ +${a}{ } diff --git a/toke.c b/toke.c index bfe282c..3e611e9 100644 --- a/toke.c +++ b/toke.c @@ -6276,8 +6276,10 @@ S_scan_ident(pTHX_ register char *s, register char *send, char *dest, STRLEN des } if (*s == '}') { s++; - if (PL_lex_state == LEX_INTERPNORMAL && !PL_lex_brackets) + if (PL_lex_state == LEX_INTERPNORMAL && !PL_lex_brackets) { PL_lex_state = LEX_INTERPEND; + PL_expect = XREF; + } if (funny == '#') funny = '@'; if (PL_lex_state == LEX_NORMAL) { @@ -6289,8 +6291,6 @@ S_scan_ident(pTHX_ register char *s, register char *send, char *dest, STRLEN des funny, dest, funny, dest); } } - if (PL_lex_inwhat == OP_STRINGIFY) - PL_expect = XREF; } else { s = bracket; /* let the parser handle it */