This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #114222] Make ‘use’ parse arguments in term context
authorFather Chrysostomos <sprout@cpan.org>
Sat, 4 Aug 2012 01:35:26 +0000 (18:35 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 4 Aug 2012 02:40:30 +0000 (19:40 -0700)
commit52d0e95bfa64548328a8cb945b92a6ff4892a5ad
tree57b698a1f1e1468c471db7331a8b3e8eef2de756
parentcf26f5d571f7d70d3c224acf75da4164e6a353c2
[perl #114222] Make ‘use’ parse arguments in term context

(lexing context, that is)

use constant { () }

was a syntax error, because the lexer was guessing when { should be
a statement or hash.

It should not be doing that where a term is expected.

It was actually getting itself confused, and trying to parse the
argument list as a statement.

Setting PL_expect after force_next is ineffectual, as force_next
records the current value of PL_expect, arranging to have it
restored.

OPERATOR(USE) was setting PL_expect, but too late.  So no we set
PL_expect explicitly in S_tokenize_use, before any forced tokens,
and use TOKEN(USE), which does not set PL_expect (as setting it
there has no effect).
t/comp/use.t
toke.c