-
-
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.mapping cannot have properties
key
#4595
Comments
Yes, in this case, the call to JSON.mapping({
properties: Hash(String, String),
}) |
You can use it like this: require "json"
class Foo
JSON.mapping({
properties: Hash(String, String),
})
end
p Foo.from_json({ properties: { "foo" => "bar" }, }.to_json) Note that I'm passing a NamedTuple to |
Considering that the notation without braces is encouraged by the example in the API docs and |
Isn't this solved by #236? |
No, this is not related. The signature of macro def mapping(properties, strict = false) When you call it like in the above example, the compiler assumes, |
So this issue could be avoided for the specific value of macro def mapping(mapping_properties, strict = false) I realize that doesn't really solve anything, it just changes where the collision occurs. |
... and thus makes a collision less likely. |
Whatever name we choose, there will always be the possibility of a collision. There's also the We can maybe remove the named arguments overload. |
Is it currently possible to remove an argument from name-matching? |
@straight-shoota I think @asterite mean that as a change in the compiler. Syntax-wise I think we could allow But is definitely simpler for now to change that name for now. Adding that kind of syntax seems nice and neat, but there are thing to check and disallow when mixing many |
Oh, yes, I think we can just rename |
As #5180 has been merged, can we close this issue? |
Given the following code:
This doesn't work, but if you change
properties
to something else, it does.properties
doesn't appear to be a language keyword, so I don't think it's the same problem as #284, but I figure it might be caused byproperties
being used in theJSON.mapping
macro.I'm currently making it work with
props: { type: JSON::Any, key: "properties" }
, but ifproperties
isn't already a method on a JSON-mapped class, it makes sense to be able to use it.The text was updated successfully, but these errors were encountered: