diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-08-27 18:16:34 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-08-27 23:24:02 -0700 |
commit | 78a635de15dde640c98d94757206df013d18a651 (patch) | |
tree | e701457c41931f9473e4a2090722a5c8a808a560 /t/comp | |
parent | 4b1709c81eda847f426abd956588d275ab068d2c (diff) | |
download | perl-78a635de15dde640c98d94757206df013d18a651.tar.gz |
Fix line numbers inside here-docs
A previous commit put the number of lines in a here-doc in a separ-
ate parser field, which was added on to the line number at the next
CopLINE_inc (actually COPLINE_INC_WITH_HERELINES, now used through-
out toke.c).
Code interpolated inside the here-doc was picking up that value,
throwing line numbers off.
Before that, they were already off by one.
This commit fixes both.
I removed the CLINE from S_scan_heredoc and stopped using TERM (which
uses CLINE) for here-docs. CLINE sets PL_copline, which is used to
pass a specific line number to newSTATEOP, which may or may not be the
same number as CopLINE(PL_curcop). newSTATEOP grabs that number and
sets PL_copline to -1 (aka NOLINE). I assume this was used to make
the statement containing the <<foo marker have the right line number.
But it didn’t fully work out, as subsequent statements on the same
line had the wrong number. That I fixed a few commits ago when I
introduced herelines, making CopLINE(PL_curcop) have the right line
number for that line. So the CLINE is not actually necessary anymore.
It was causing a problem also with the first statement inside the
heredoc (in ${...}), which would ‘steal’ the line number of the
<<foo marker.
This also means that <FH> and <.*> no longer do CLINE, but it is not
necessary, as they cannot span multiple lines.
Diffstat (limited to 't/comp')
-rw-r--r-- | t/comp/parser.t | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/t/comp/parser.t b/t/comp/parser.t index a89294968f..27f81dc61a 100644 --- a/t/comp/parser.t +++ b/t/comp/parser.t @@ -3,7 +3,7 @@ # Checks if the parser behaves correctly in edge cases # (including weird syntax errors) -print "1..148\n"; +print "1..152\n"; sub failed { my ($got, $expected, $name) = @_; @@ -533,6 +533,10 @@ EOU s//<<EOV/e if 0; EOV check('parser\.t', 535, 'after here-doc in quotes'); +<<EOW; +${check('parser\.t', 537, 'first line of interp in here-doc');; + check('parser\.t', 538, 'second line of interp in here-doc');} +EOW __END__ # Don't add new tests HERE. See note above |