summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-10-22 19:32:04 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-10-22 19:50:48 -0700
commit51a82aa9fb28c58b85d2a2e89872685010ffa91c (patch)
tree00c03bdebe06be0dc6f64a95ca117e2995e0d00f /t
parent551992550541be7bd63c953d9a52701192115a6c (diff)
downloadperl-51a82aa9fb28c58b85d2a2e89872685010ffa91c.tar.gz
[perl #122695] Fix line number for else{foo}
where there is no space after the opening brace. The code that was responsible for the wrong line number: if (isSPACE(*s) || *s == '#') PL_copline = NOLINE; /* invalidate current command line number */ was added in perl *2.0* (378cc40b3)! It looked a little different back then: if (isspace(*s) || *s == '#') cmdline = NOLINE; /* invalidate current command line number */ I don’t know what the condition was for. I can only imagine that it seemed logical to skip the setting of cmdline if it appeared to be something on the same line (e.g., if($foo){bar()} as opposed to if($foo){<newline>...}). Clearly that doesn’t work for ‘else{foo()}’ because we end up giving that statement the line number where the ‘if’ occurs. (cmdline/PL_copline is for remembering the first line of a multi-line construct.)
Diffstat (limited to 't')
-rw-r--r--t/comp/parser.t8
-rw-r--r--t/op/runlevel.t2
2 files changed, 8 insertions, 2 deletions
diff --git a/t/comp/parser.t b/t/comp/parser.t
index ffa4dffed9..09d5632796 100644
--- a/t/comp/parser.t
+++ b/t/comp/parser.t
@@ -8,7 +8,7 @@ BEGIN {
chdir 't' if -d 't';
}
-print "1..170\n";
+print "1..171\n";
sub failed {
my ($got, $expected, $name) = @_;
@@ -503,6 +503,12 @@ eval 'method {} {$_,undef}';
like $@, qq/^Can't call method "method" on unblessed reference at /,
'method BLOCK {...} does not try to disambiguate';
+eval '#line 1 maggapom
+ if ($a>3) { $a ++; }
+ else {printf(1/0);}';
+is $@, "Illegal division by zero at maggapom line 2.\n",
+ 'else {foo} line number (no space after {) [perl #122695]';
+
# Add new tests HERE (above this line)
# bug #74022: Loop on characters in \p{OtherIDContinue}
diff --git a/t/op/runlevel.t b/t/op/runlevel.t
index 3e68a2361a..5b6b39fa37 100644
--- a/t/op/runlevel.t
+++ b/t/op/runlevel.t
@@ -169,7 +169,7 @@ foo:
@a = sort { last foo; } @a;
}
EXPECT
-Label not found for "last foo" at - line 2.
+Label not found for "last foo" at - line 4.
########
package TEST;