summaryrefslogtreecommitdiff
path: root/t/base
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-07-12 22:34:48 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-07-12 23:07:04 -0700
commit5969c5766a5d3f6b42a5140548d7c3d6812fec8b (patch)
tree822218ef2c8a6550930872e0c95767d1b5f61894 /t/base
parent8b12970a83017badfde9752dbd1480e612591839 (diff)
downloadperl-5969c5766a5d3f6b42a5140548d7c3d6812fec8b.tar.gz
Allow => to quote built-in keywords across lines
If I have a sub I can use its name as a bareword as long as I suffix it with =>, even if the => is on the next line: $ ./perl -Ilib -e 'sub tim; warn tim' -e '=>' tim at -e line 1. If I want to use a built-in keyword’s name as a bareword, I can put => after it: $ ./perl -Ilib -e 'warn time =>' time at -e line 1. But if I combine the two (keyword + newline), it does not work: $ ./perl -Ilib -e 'warn time' -e ' =>' 1373611283 at -e line 1. unless I override the keyword: $ ./perl -Ilib -Msubs=time -e 'warn time' -e ' =>' time at -e line 1. => after a bareword is checked for in two places in toke.c. The first comes before a comment saying ‘NO SKIPSPACE BEFORE HERE!’; it only skips spaces and finds a => on the same line. The second comes later; it skips vertical space and comments, too. But the second check is in a code path that is not reached by keywords that are not overridden (as is the ‘NO SKIPSPACE’ comment). This commit adds an extra check for built-in keywords after we have determined that the keyword is not overridden. In that case, there is no reason we cannot use skipspace, as we no longer have to worry about what PL_oldbufptr etc. point to. This commit leaves __DATA__ and __END__ alone, since they are special, problematic and controversial. (See, e.g., <https://rt.perl.org/rt3/Ticket/Display.html?id=78348#txn-1234355>.)
Diffstat (limited to 't/base')
-rw-r--r--t/base/lex.t6
1 files changed, 5 insertions, 1 deletions
diff --git a/t/base/lex.t b/t/base/lex.t
index 7ef753807b..7821e763a3 100644
--- a/t/base/lex.t
+++ b/t/base/lex.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..93\n";
+print "1..94\n";
$x = 'x';
@@ -443,3 +443,7 @@ y # comment
;
print "not " unless $_ eq 'b';
print "ok 93 - y <comment> <newline> ...\n";
+
+print "not " unless (time
+ =>) eq time=>;
+print "ok 94 - => quotes keywords across lines\n";