8000 Copy more grammar to RakuAST for error messages by MasterDuke17 · Pull Request #5242 · rakudo/rakudo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Copy more grammar to RakuAST for error messages #5242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

MasterDuke17
Copy link
Contributor

This gets us the right error messages/suggestions for more things (e.g., a bare say now suggests .say or &say).

Now t/spec/S16-io/bare-say.t and t/spec/S16-io/put.t are passing.

$<longname>."{$orry}obs"("bare \"$name\"", ".$name if you meant 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");
}
elsif $trap == 2 { # probably misused P6ism
$<longname>."$orry"("Function \"$name\" may not be called without arguments (please use () or whitespace to denote arguments, or &$name to refer to the function as a noun, or use .$name if you meant to call it as a method on \$_)");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually looks like a bug to me even in the old compiler. We never check if the name refers to the sub in the setting:

nine@sphinx:~/rakudo (main *=)> rakudo -e 'my sub one { 1 }; say one;'
===SORRY!=== Error while compiling -e
Function "one" may not be called without arguments (please use () or whitespace to denote arguments, or &one to refer to the function as a noun, or use .one if you meant to call it as a method on $_)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been looking for something like .is_from_core from src/Perl/Optimizer.nqp in src/Raku/*, but the closest thing seems to be .resolve-name-constant-in-setting, which I don't think does what I want. Am I missing something obvious?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh hm, maybe I can/should do it the other way round, and use something like .find-lexical...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need both. You need to resolve the symbol lexically and also find the equivalent symbol in the setting and check whether they are identical. However you should not call find-lexical directly. This method must be called only after the AST is complete, as it will create a cache for the lexicals it finds and never look at the AST again.
So I think this check actually belongs in a PERFORM-CHECK method of a node that does RakuAST::CheckTime rather than in the grammar. That said, I think calling these without arguments is actually allowed if followed by parenthesis, e.g. say() - a distinction which might be lost in the AST.

@MasterDuke17 MasterDuke17 force-pushed the copy_deftraps_to_rakuast branch from a88fee0 to dcdff7d Compare May 2, 2023 01:31
@MasterDuke17 MasterDuke17 force-pushed the copy_deftraps_to_rakuast branch from dcdff7d to 3f4a3a9 Compare August 30, 2023 01:57
@lizmat lizmat marked this pull request as draft September 29, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5CB3
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0