summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-09-24 18:18:42 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-09-25 06:27:55 -0700
commite9d2327de9f57c23ca9f4b2b17818e696b0b031e (patch)
tree8602bc5cfd9169c1fd7729b6aaabaea81f2aa610
parent7ce06b7dca2247fac16c28cd064f3949998cb06e (diff)
downloadperl-e9d2327de9f57c23ca9f4b2b17818e696b0b031e.tar.gz
[perl #56880] Allow v10 as a label or package name
-rw-r--r--t/base/lex.t22
-rw-r--r--toke.c10
2 files changed, 30 insertions, 2 deletions
diff --git a/t/base/lex.t b/t/base/lex.t
index bca43b4570..b1c4a09992 100644
--- a/t/base/lex.t
+++ b/t/base/lex.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..81\n";
+print "1..85\n";
$x = 'x';
@@ -380,3 +380,23 @@ for(qw< require goto last next redo dump >) {
print "ok ", $test++, " - [perl #105924] $_ WORD << ...\n";
print "# $@" if $@;
}
+
+# http://rt.perl.org/rt3/Ticket/Display.html?id=56880
+my $counter = 0;
+eval 'v23: $counter++; goto v23 unless $counter == 2';
+print "not " unless $counter == 2;
+print "ok 82 - Use v[0-9]+ as a label\n";
+$counter = 0;
+eval 'v23 : $counter++; goto v23 unless $counter == 2';
+print "not " unless $counter == 2;
+print "ok 83 - Use v[0-9]+ as a label with space before colon\n";
+
+my $output = "";
+eval "package v10::foo; sub test2 { return 'v10::foo' }
+ package v10; sub test { return v10::foo::test2(); }
+ package main; \$output = v10::test(); ";
+print "not " unless $output eq 'v10::foo';
+print "ok 84 - call a function in package v10::foo\n";
+
+print "not " unless (1?v65:"bar") eq 'A';
+print "ok 85 - colon detection after vstring does not break ? vstring :\n";
diff --git a/toke.c b/toke.c
index d22551460e..e9a06eb423 100644
--- a/toke.c
+++ b/toke.c
@@ -6553,8 +6553,16 @@ Perl_yylex(pTHX)
s = scan_num(s, &pl_yylval);
TERM(THING);
}
+ else if ((*start == ':' && start[1] == ':')
+ || (PL_expect == XSTATE && *start == ':'))
+ goto keylookup;
+ else if (PL_expect == XSTATE) {
+ d = start;
+ while (d < PL_bufend && isSPACE(*d)) d++;
+ if (*d == ':') goto keylookup;
+ }
/* avoid v123abc() or $h{v1}, allow C<print v10;> */
- else if (!isALPHA(*start) && (PL_expect == XTERM
+ if (!isALPHA(*start) && (PL_expect == XTERM
|| PL_expect == XREF || PL_expect == XSTATE
|| PL_expect == XTERMORDORDOR)) {
GV *const gv = gv_fetchpvn_flags(s, start - s,