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

Add warning macro #13262

Merged
merged 2 commits into from
Apr 18, 2023
Merged

Conversation

Blacksmoke16
Copy link
Member

Resolves #9246

Copy link
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

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

It would be nice to also check the location of the warning. But that can come as a future enhancement to assert_warning.

@straight-shoota straight-shoota added this to the 1.9.0 milestone Apr 1, 2023
Comment on lines +2690 to +2694
msg = args.map do |arg|
arg.accept interpreter
interpreter.last.to_macro_id
end
msg = msg.join " "
Copy link
Member Author

@Blacksmoke16 Blacksmoke16 Apr 1, 2023

Choose a reason for hiding this comment

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

While playing with the other macro error stuff I noticed that you can actually pass a variadic amount of arguments to macro raise? This keeps that behavior for consistency, but could also do a follow up to make it an error if are 0 or more than 1 arguments passed to #warning and add a deprecation to #raise.

$ crystal run --error-trace test.cr 
In test.cr:1:1

 1 | {% raise "foo", "bar", 123 %}
     ^
Error: foo bar 123

@straight-shoota straight-shoota merged commit 37f392d into crystal-lang:master Apr 18, 2023
@Blacksmoke16 Blacksmoke16 deleted the astnode-warnings branch April 18, 2023 13:11
@straight-shoota straight-shoota changed the title Add macro #warning method Add warning macro Jul 2, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ASTNode.warning macro method
2 participants