summaryrefslogtreecommitdiff
path: root/pod
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2017-07-25 14:36:28 +1000
committerTony Cook <tony@develop-help.com>2017-09-19 10:55:23 +1000
commit08ccc81012771c7ca6dc701881d86876ceb40e54 (patch)
tree2da35c0b4acc211651d1ae31c75dfc87a0ec5f05 /pod
parent570a6dbb8c57e331a0496105a6acdc1f06e03496 (diff)
downloadperl-08ccc81012771c7ca6dc701881d86876ceb40e54.tar.gz
(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.
Diffstat (limited to 'pod')
-rw-r--r--pod/perldiag.pod11
1 files changed, 11 insertions, 0 deletions
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 689e9609bc..d417fb296e 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -2652,6 +2652,17 @@ this error when Perl was built using standard options. For some
reason, your version of Perl appears to have been built without
this support. Talk to your Perl administrator.
+=item Illegal operator following parameter in a subroutine signature
+
+(F) A parameter in a subroutine signature, was followed by something
+other than C<=> introducing a default, C<,> or C<)>.
+
+ use feature 'signatures';
+ sub foo ($=1) {} # legal
+ sub foo ($a = 1) {} # legal
+ sub foo ($a += 1) {} # illegal
+ sub foo ($a == 1) {} # illegal
+
=item Illegal character following sigil in a subroutine signature
(F) A parameter in a subroutine signature contained an unexpected character