Skip to content

Commit e3c970e

Browse files
committed
include any<foo bar> in illegal forms
We've been checking for bare 'say' and such; the misuse of 'any' can be in the same spot, but deserves a different message since it's (probably) not intended to default to $_. Also, both messages are fatal now. (In the long run, the %deftrap hash probably wants to be a trait on the proto sub so that user-defined functions can get the same treatment.)
1 parent 516268a commit e3c970e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

STD.pm6

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3970,7 +3970,9 @@ grammar P6 is STD {
39703970
:defined, :eval, :exp, :glob, :lc, :lcfirst, :log, :lstat, :mkdir,
39713971
:ord, :readlink, :readpipe, :require, :reverse, :rmdir, :sin,
39723972
:split, :sqrt, :stat, :uc, :ucfirst, :unlink,
3973-
:WHAT, :WHICH, :WHERE, :HOW, :WHENCE, :VAR,
3973+
:WHAT(2), :WHICH(2), :WHERE(2), :HOW(2), :WHENCE(2), :WHO(2),
3974+
:VAR(2),
3975+
:any(2), :all(2), :none(2), :one(2),
39743976
);
39753977

39763978
# force identifier(), identifier.(), etc. to be a function call always
@@ -4001,7 +4003,14 @@ grammar P6 is STD {
40014003
$ok = 1 if $al and $al.from != $al.to;
40024004
$ok = 1 if $<args><semiarglist>;
40034005
if not $ok {
4004-
$<identifier>.worryobs("bare '$name'", ".$name if you meant \$_, or use an explicit invocant or argument");
4006+
given +%deftrap{$name} {
4007+
when 1 { # probably misused P5ism
4008+
$<identifier>.sorryobs("bare '$name'", ".$name if you meant \$_, or use an explicit invocant or argument");
4009+
}
4010+
when 2 { # probably misused P6ism
4011+
$<identifier>.sorry("The '$name' listop may not be called without arguments (please use () or whitespace to clarify)");
4012+
}
4013+
}
40054014
}
40064015
}
40074016
}

0 commit comments

Comments
 (0)