File tree Expand file tree Collapse file tree 3 files changed +29
-9
lines changed Expand file tree Collapse file tree 3 files changed +29
-9
lines changed Original file line number Diff line number Diff line change @@ -248,6 +248,15 @@ sigil; for example:
248248
249249 sub foo ($x, $, $y = 1, @z) {}
250250
251+ =item A named signature parameter must start with '$'
252+
253+ (F) Each subroutine signature parameter declaration that declares a named
254+ parameter must start with a scalar variable sigil; for example:
255+
256+ sub foo (:$x, :$y, :$z) {}
257+
258+ Array and hash variables are not permitted as named parameters.
259+
251260=item A slurpy parameter may not have a default value
252261
253262(F) Only scalar subroutine signature parameters may have a default value;
@@ -4865,13 +4874,6 @@ C<sysread()>ing a file, or when seeking past the end of a scalar opened
48654874for I/O (in anticipation of future reads and to imitate the behavior
48664875with real files).
48674876
4868- =item Only a scalar parameter may be named
4869-
4870- (F) An attempt was made to use an array or hash variable as a named parameter.
4871-
4872- sub foo (:@name) {...}
4873- sub foo (:%name) {...}
4874-
48754877=item Only scalar fields can take a :param attribute
48764878
48774879(F) You tried to apply the C<:param> attribute to an array or hash field.
Original file line number Diff line number Diff line change @@ -216,6 +216,21 @@ EXPECT
216216Illegal operator following parameter in a subroutine signature at - line 2, near "(:$a :"
217217syntax error at - line 2, near "(:$a :"
218218########
219+ sub named (:@x) { }
220+ EXPECT
221+ A named signature parameter must start with '$' at - line 2, near "(:@"
222+ syntax error at - line 2, near ":@x"
223+ ########
224+ sub named (:%x) { }
225+ EXPECT
226+ A named signature parameter must start with '$' at - line 2, near "(:%"
227+ syntax error at - line 2, near ":%x"
228+ ########
229+ sub t094_named (:123) { }
230+ EXPECT
231+ A named signature parameter must start with '$' at - line 2, near "(:1"
232+ syntax error at - line 2, near "(:123"
233+ ########
219234sub t097 ($a { }) { }
220235EXPECT
221236Illegal operator following parameter in a subroutine signature at - line 2, near "($a { }"
Original file line number Diff line number Diff line change @@ -5508,7 +5508,7 @@ yyl_sigvar(pTHX_ char *s)
55085508 break ;
55095509 }
55105510 if (is_named && sigil != '$' ) {
5511- yyerror ("Only a scalar parameter may be named " );
5511+ yyerror ("A named signature parameter must start with '$' " );
55125512 break ;
55135513 }
55145514 s = skipspace (s );
@@ -5586,7 +5586,10 @@ yyl_sigvar(pTHX_ char *s)
55865586
55875587 default :
55885588 PL_in_my = 0 ;
5589- yyerror ("A signature parameter must start with '$', '@' or '%'" );
5589+ if (is_named )
5590+ yyerror ("A named signature parameter must start with '$'" );
5591+ else
5592+ yyerror ("A signature parameter must start with '$', '@' or '%'" );
55905593 /* very crude error recovery: skip to likely next signature
55915594 * element */
55925595 while (* s && * s != '$' && * s != '@' && * s != '%' && * s != ')' )
You can’t perform that action at this time.
0 commit comments