Add dict literal syntax
This PR adds basic support for the dict{} literal syntax (https://github.com/rescript-lang/rescript-compiler/issues/6545).
Parsing
Semantics within the braces are similar to the record with string keys (as dict keys can be any string).
It then turns dict{"foo": "bar"} into Js.Dict.fromArray([("foo", "bar")]).
Printing
Any Js.Dict.fromArray call that contains a literal array of tuples (with no spread) is now printed as dict{...}.
I think this change is safe for the upcoming stdlib change (that'll move Js.Dict into Dict) as the change will be invisible once using this syntax. If that's something we don't want, we can add an attribute when parsing a dict{} expression so that we only print those back and leave Js.Dict.fromArray calls.
Can you add a changelog entry?
Could you remove the unrelated changes in belt_HashSetString.resi and belt_HashSetInt.resi?
If that's something we don't want, we can add an attribute when parsing a dict{} expression so that we only print those back and leave Js.Dict.fromArray calls.
An attribute somehow might actually be beneficial for the editor tooling, if we want to do typed completion for values for instance.
@zth aren't the rules the same as (Js.)Dict.fromArray? couldn't we generalize autocompletion here?
I'm also curious for the use case of the editor tooling =D Wouldn't we want to upgrade codebases automatically through the formatter?
Just noting #6617 supports spread syntax if you want to vendor anything across.
@bloodyowl What's the status of this PR? Would be great to get this feature merged!
Yes, I agree. This would be a cool feature to have.
@zth Rebased