-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
JSON: Change properties key to _properties_ to reduce chance of conflict #5180
Conversation
macro mapping(properties, strict = false) | ||
{% for key, value in properties %} | ||
{% properties[key] = {type: value} unless value.is_a?(HashLiteral) || value.is_a?(NamedTupleLiteral) %} | ||
macro mapping(_properties_, strict = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does %properties work for macro arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, syntax error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That wouldn't make sense, because the macro argument properties
is a macro-level variable, whereas %
-prefixed variables are local variables in the generated code. This are two different levels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it obviously doesn't work, but it is unfortunate that it is impossible to avoid collisions.
Thanks for your contribution @maxpowa!!! It seems that CI failed due differences in the format. Can you make sure For more details, please see the documentation about coding styles Thank you! |
07d8645
to
e4beb7d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! But we still have this problem with the strict
property, though I don't know how to solve that. In any case, one can pass a Hash or NamedTuple to avoid clashing with properties
or strict
, so this change is not strictly necessary, but still welcome.
@asterite I don't think It would perhaps be possible to introduce a special check if |
Relates to #4595,
_properties_
is less likely to conflict thanproperties
is.