Skip to content

Commit

Permalink
RakuAST: add sorry for use of say/put/print w/o args
Browse files Browse the repository at this point in the history
This is a reduced version of the logic that exists in the legacy
grammar, which think we shouldn't copy over to the Raku grammar.

The reason I'm adding this check for say/put/print, is that they
would be the most common cases, **and** there is a spectest for
at last a bare "put".  But frankly, I'd rather get rid of this
all.
  • Loading branch information
lizmat committed Aug 12, 2023
1 parent bfc5af6 commit c1f7e4d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Raku/Grammar.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -2023,14 +2023,25 @@ grammar Raku::Grammar is HLL::Grammar does Raku::Common {
]?
|| [ \\ <?before '('> ]? <args(1)>
{
my $name := ~$<longname>;
if !$<args><invocant> {
my $name := ~$<longname>;
if $*BORG<block> {
unless $*BORG<name> {
$*BORG<name> := $*BORG<name> // $name;
}
}
}
unless $*LANG.pragma('p5isms') {
if $name eq 'say' || $name eq 'put' || $name eq 'print' {
my $al := $<args><arglist>;
my int $ok := 0;
$ok := 1 unless $al<EXPR> eq '';
$ok := 1 if $<args><semiarglist>;
unless $ok {
$<longname>.sorryobs("bare \"$name\"", ".$name if to call it as a method on \$_, or use an explicit invocant or argument, or use &$name to refer to the function as a noun");
}
}
}
}
]
}
Expand Down

0 comments on commit c1f7e4d

Please sign in to comment.