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

Fix error message for calling record macro with kwargs #13367

Merged
merged 7 commits into from
May 12, 2023
10 changes: 9 additions & 1 deletion src/macros.cr
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@
# p.copy_with x: 3 # => #<Point(@x=3, @y=2)>
# p # => #<Point(@x=0, @y=2)>
# ```
macro record(name, *properties)
macro record(__name, *properties, **kwargs)
{% raise <<-TXT unless kwargs.empty?
macro `record` does not accept named arguments
Did you mean:

record #{name}, #{(properties + kwargs.map { |name, value| "#{name} : #{value}" }).join(", ").id}
TXT
%}
a-alhusaini marked this conversation as resolved.
Show resolved Hide resolved

struct {{name.id}}
{% for property in properties %}
{% if property.is_a?(Assign) %}
Expand Down