-
Notifications
You must be signed in to change notification settings - Fork 449
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
Specialize uses of new dict literal to direct JS object creation #6538
Conversation
What about RescriptCore.Dict.fromArray? |
Yeah that's a good point, we should make sure this PR handles both. |
Dict should be promoted to a built in type and specialized that way instead. |
45b4d6a
to
f67c121
Compare
@cristianoc please have a look at whether this approach is good and if the optimization is in the correct place. Maybe it could be put somewhere else? When Core moves into the compiler (#6761) then we'll change this to account for |
f261c58
to
41af695
Compare
Got a ton of unrelated changes here rebasing, including to test JS files. Not sure why. Also changes to |
build.ninja has changed because DictTest.res was added. The line number changes in the JS output must be from a previous PR, maybe I forgot to check those in when reformatting the tests. |
@cknitt could you check if that's the case, with the reformatting in master? |
Yes, I currently get the same JS output files changed on master. |
Shall I create a separate PR for committing those JS output changes? |
520d0e6
to
58f541e
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.
Looks good.
Left comment on robustness of path detection.
58f541e
to
ad43ed0
Compare
@cristianoc check again please. I changed the approach to use a builtin primitive instead, and it now only works on the new |
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.
Looks great
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.
The only minor comment is the syntax does not let us remove Js.Dict in future.
Just adding a reminder issue should be enough I think. Or in the issue about moving core into the compiler.
Why is that? This is in the syntax so we should be able to just change the path the dict literal produces, no? Regardless, maybe there's a better module to put this and other internal-only functions like for
What do you think? Another observation on this change - previously there was a wip PR that added spreads to dicts, which is quite nice. That's probably a bit harder to achieve with this structure. And it's a nice feature, so it'd be cool to have it at some point. |
Trying to figure out why the syntax roundtrip tests still are broken. |
Sounds like a great idea. |
you did not check in the changes -- les's see if CI works now |
@cristianoc @cknitt look again, the creator fn is now in its own runtime module. |
can you check that the dict syntax is not formatted away? |
@@ -0,0 +1,8 @@ | |||
let someString = "hello" | |||
|
|||
let createdDict = dict{ |
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.
Maybe also add a Dict<int>
for testing?
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.
Sure, adding.
ship it |
Any timeline on the next alpha? |
@nojaf not sure, but probably not too far away. We can release the alphas pretty much whenever we want to. |
A Dict is obviously a JS object at runtime, but there has been no way to create a dict in a way that compiles to a regular JS object creation. This can be a bit confusing when looking at the generated code, as well as hurt performance (albeit slightly in most cases) as creating dict objects are done dynamically via an array.
This changes so that any usage of the new
dict{}
literal gets compiled to an actual JS object creation.Related issues: