diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-10-10 13:14:31 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-10-10 13:15:14 -0700 |
commit | 451f421fe4742646fa2efbed0f45a19f0713d00f (patch) | |
tree | 7d78530b99142d67abb214536f34b6a944658656 /t/op/eval.t | |
parent | 73f2c082cce3e45af05f993af5e9294bb30e6ee5 (diff) | |
download | perl-451f421fe4742646fa2efbed0f45a19f0713d00f.tar.gz |
[perl #114658] Fix line numbers at the end of string eval
$ perl -e 'eval "{;"; print $@'
Missing right curly or square bracket at (eval 1) line 1, at end of line
syntax error at (eval 1) line 1, at EOF
$ perl -e 'eval "{"; print $@'
Missing right curly or square bracket at (eval 1) line 2, at end of line
syntax error at (eval 1) line 2, at EOF
Notice how the line number goes up when there is no semicolon.
What happens is that eval tacks "\n;" on to the end of the string if
it does not already end with a semicolon.
I actually changed this in blead in commit 11076590 to tack "\n;"
on to the end all the time, to make eval "q;;" and
eval "return #comment;" work.
This caused the line number to increase for eval "{;".
This commit fixes both examples above by modifying S_incline to
account for the "\n;" at the end of a string eval.
Existing tests had to be modified, as they were testing for the wrong
line number.
Diffstat (limited to 't/op/eval.t')
-rw-r--r-- | t/op/eval.t | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/t/op/eval.t b/t/op/eval.t index 9866ca7130..49f7494201 100644 --- a/t/op/eval.t +++ b/t/op/eval.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan(tests => 126); +plan(tests => 128); eval 'pass();'; @@ -609,3 +609,12 @@ pass("phew! dodged the assertion after a parsing (not lexing) error"); qr/Unbalanced string table/, 'Errors in finalize_optree do not leak string eval op tree'; } + +# [perl #114658] Line numbers at end of string eval +for("{;", "{") { + eval $_; is $@ =~ s/eval \d+/eval 1/rag, <<'EOE', +Missing right curly or square bracket at (eval 1) line 1, at end of line +syntax error at (eval 1) line 1, at EOF +EOE + qq'Right line number for eval "$_"'; +} |