-
Notifications
You must be signed in to change notification settings - Fork 26
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
Consider restricting attribute keys syntax to identifiers and strings again #145
Comments
The other thing that I find sort of strange here is that the argument is that we're trying to be symmetric with the object literal version for dynamic import, but the syntax ends up still being a subset of the object literal syntax. For example,
won't parse -- IMO having a tighter simpler rule for the WithClause makes more sense than trying to align it with the dynamic import case. |
It looks like JSC currently allocates bigints while parsing, but they would like to stop doing so: V8 allocates bigints while parsing without problems |
Also cc @tc39/ecma262-editors, since the keys syntax was relaxed due to feedback from the stage 3 review 🙂 |
I don't understand the problem. BigInts are only allocated when someone uses them as keys. |
The spec requires that duplicate assertion keys are detected and reported as syntax errors; but that means that we need to be able to report that However, as a design principle we are not allocating GC things during parse; this would be an instance of us having to do so. |
(for regular numeric values we have specialized machinery to handle this, but since a bigint is arbitrary precision, we would need the full arbitrary precision comparison) |
Forgive me if i don't understand some nuance of parsers, but if it's successfully parsed as a bigint, you can't just remove the |
@ljharb No, the BigInt grammar is not otherwise canonicalising. |
ah, i forgot about hex literals, fair point |
Regardless, though, I am skeptical of the claim that a parser must instantiate an actual JS BigInt to be able to detect duplicate keys. You don't need to allocate an actual BigInt to compute edit: And this cost, even if excessive, is only paid when the program actually uses this combination of features (import assertions with bigint keys), which will be exceptionally rare. |
It's definitely possible in principle. Seems like an awful lot of work to ask of implementations for something which isn't ever actually going to be used, though. |
Just implemented an attributes parser, with numeric literal support. I was surprised it was there. Just some thoughts:
I don't have strong feelings. Following this so my parser can stay aligned with whatever happens. |
Original commit message: [import-attributes] Remove support for numeric keys During the 2023-09 TC39 meeting the proposal has been updated to remove support for bigint and float literals as import attribute keys, due to implementation difficulties in other engines and minimal added value for JS developers. GH issue: tc39/proposal-import-attributes#145 Bug: v8:13856 Change-Id: I0ede2bb10d6ca338a4b0870a1261ccbcd088c16f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4899760 Reviewed-by: Shu-yu Guo <[email protected]> Commit-Queue: Joyee Cheung <[email protected]> Cr-Commit-Position: refs/heads/main@{#90318} Refs: v8/v8@ea996ad
Original commit message: [import-attributes] Remove support for numeric keys During the 2023-09 TC39 meeting the proposal has been updated to remove support for bigint and float literals as import attribute keys, due to implementation difficulties in other engines and minimal added value for JS developers. GH issue: tc39/proposal-import-attributes#145 Bug: v8:13856 Change-Id: I0ede2bb10d6ca338a4b0870a1261ccbcd088c16f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4899760 Reviewed-by: Shu-yu Guo <[email protected]> Commit-Queue: Joyee Cheung <[email protected]> Cr-Commit-Position: refs/heads/main@{#90318} Refs: v8/v8@ea996ad PR-URL: #50183 Reviewed-By: Geoffrey Booth <[email protected]>
Original commit message: [import-attributes] Remove support for numeric keys During the 2023-09 TC39 meeting the proposal has been updated to remove support for bigint and float literals as import attribute keys, due to implementation difficulties in other engines and minimal added value for JS developers. GH issue: tc39/proposal-import-attributes#145 Bug: v8:13856 Change-Id: I0ede2bb10d6ca338a4b0870a1261ccbcd088c16f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4899760 Reviewed-by: Shu-yu Guo <[email protected]> Commit-Queue: Joyee Cheung <[email protected]> Cr-Commit-Position: refs/heads/main@{#90318} Refs: v8/v8@ea996ad PR-URL: #51136 Reviewed-By: Yagiz Nizipli <[email protected]>
Original commit message: [import-attributes] Remove support for numeric keys During the 2023-09 TC39 meeting the proposal has been updated to remove support for bigint and float literals as import attribute keys, due to implementation difficulties in other engines and minimal added value for JS developers. GH issue: tc39/proposal-import-attributes#145 Bug: v8:13856 Change-Id: I0ede2bb10d6ca338a4b0870a1261ccbcd088c16f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4899760 Reviewed-by: Shu-yu Guo <[email protected]> Commit-Queue: Joyee Cheung <[email protected]> Cr-Commit-Position: refs/heads/main@{#90318} Refs: v8/v8@ea996ad
BigInt attribute keys (i.e.
import "x" with { 10n: "val" }
) need to be converted to strings while parsing, to check for duplicate keys. In SpiderMonkey this would require allocating the bigint at parse time, which is something that does not currently happen (the object{ 10n: x }
is parsed as{ [10n]: x }
).The motivation for allowing number&bigint literals in import attribute keys is for symmetry with object literals.
The text was updated successfully, but these errors were encountered: