-
-
Notifications
You must be signed in to change notification settings - Fork 658
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
Allow object."field"
syntax (see #7722)
#9433
Conversation
I'm glad you asked. I think we all agree that what we really want is this: class Awesome {
final "🔫🦈" = "LaserShark";
} |
I actually just tested this and have to regretfully inform that this doesn't work for class fields due to another sanity check pass :) |
maybe it should tho, if we want to pass a class to some extern API that uses structural typing and weird field names... |
Honestly, I feel like this raises more questions and surfaces more awkwardness (e.g. how to generate such fields on not-js) and is more breaking (if we change macro structures, as we should) than the |
Wow that was fast! Thanks @nadako. I'm excited for this one – often I load config files and pathnames into structures at compile time (many of which are not valid idents) so this change will massively improve things there! |
Yep, it took only 7 years ^^ |
Can we not have an ident validator in
Hmmmm. The parser might as well swallow the distinction between quoted and unquoted fields (ok, for the time being we should keep it for object literal fields for compatibility, but the quote status should be ignored in the typer). Field names would be plain strings and the typer would check them via what's in |
That's what happening at the moment, but it is a problem, because the information is lost at the point where it comes into reification functions (e.g. |
Implements #7722.
Unresolved:
macro o."$id"
(also needs EField quote status),macro {"$id": e}
andmacro : {"$id":Int}
(needs quote status too) (anything else?)Tooling comments: