This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
(perl #131777) prevent non-'=' assign ops tokens in sub signatures
authorTony Cook <tony@develop-help.com>
Tue, 25 Jul 2017 04:36:28 +0000 (14:36 +1000)
committerTony Cook <tony@develop-help.com>
Tue, 19 Sep 2017 00:55:23 +0000 (10:55 +1000)
commit08ccc81012771c7ca6dc701881d86876ceb40e54
tree2da35c0b4acc211651d1ae31c75dfc87a0ec5f05
parent570a6dbb8c57e331a0496105a6acdc1f06e03496
(perl #131777) prevent non-'=' assign ops tokens in sub signatures

The yacc grammar introduced in d3d9da4a7 uses ASSIGNOP to
represent the '=' used to introduce default values in subroutine
signatures, unfortunately the parser returns ASSIGNOP for non-simple
assignments, which allowed:

  sub foo ($x += 1) { ... }

to default $x to 1.

Modify yylex to accept only the simple assignment operator after a
subroutine parameter.

I'm not especially happy with the error recovery here.
pod/perldiag.pod
t/lib/croak/toke
t/op/signatures.t
toke.c