Skip to content
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

Unhelpful error when using named arguments on macro methods that do not support them #15310

Open
Blacksmoke16 opened this issue Dec 22, 2024 · 0 comments
Labels
good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. kind:feature topic:lang:macros

Comments

@Blacksmoke16
Copy link
Member

This was brought up on the Discord, where the reduced code was something like:

https://play.crystal-lang.org/#/r/hj72

macro test(node)
  {% pp node.type.name generic_args: false %}
end
 
test name : Array(Int32)
In test.cr:5:1

 5 | test name : Array(Int32)
     ^---
Error: expanding macro


In test.cr:2:19

 2 | {% pp node.type.name generic_args: false %}
                     ^---
Error: named arguments are not allowed here


In test.cr:5:13

 5 | test name : Array(Int32)
                 ^
Error: named arguments are not allowed here

The trace points you to the right place, but the error could be a bit better. Maybe something along the lines of:

'Generic#name' does not allow named arguments

to make it more clear what specific overload does not support them.

@Blacksmoke16 Blacksmoke16 added kind:feature topic:lang:macros good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. labels Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. kind:feature topic:lang:macros
Projects
None yet
Development

No branches or pull requests

1 participant