Skip to content
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

Normative: Add Import Attributes #3057

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented May 8, 2023

This proposal (https://tc39.es/proposal-import-attributes/, https://github.com/tc39/proposal-import-attributes) reached stage 3 during the March 2023 meeting, conditional on stage 3 reviews. I'm opening this PR before "real" stage 3 to help editors reviewing the full spec changes.

The proposal has already been integrated in HTML: https://html.spec.whatwg.org/#hostloadimportedmodule

PREVIEW: https://ci.tc39.es/preview/tc39/ecma262/pull/3057
DIFF: https://arai-a.github.io/ecma262-compare/?pr=3057 (note: the diff doesn't mark deprecated sections)

spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
@nicolo-ribaudo nicolo-ribaudo added normative change Affects behavior required to correctly evaluate some ECMAScript source text pending stage 4 This proposal has not yet achieved stage 4, but may otherwise be ready to merge. proposal This is related to a specific proposal, and will be closed/merged when the proposal reaches stage 4. needs test262 tests The proposal should specify how to test an implementation. Ideally via github.com/tc39/test262 and removed pending stage 4 This proposal has not yet achieved stage 4, but may otherwise be ready to merge. labels May 8, 2023
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
@nicolo-ribaudo
Copy link
Member Author

nicolo-ribaudo commented May 22, 2023

@tc39/ecma262-editors Currently the only remaining condition for this proposal to be actually Stage 3 is the editorial review. It'd be great if you have time to do it :)

@bakkot bakkot added the editor call to be discussed in the next editor call label May 24, 2023
@ljharb ljharb force-pushed the import-attributes branch from 891ceab to 2521cf5 Compare May 31, 2023 21:41
Copy link
Contributor

@bakkot bakkot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than comments.

spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
@nicolo-ribaudo
Copy link
Member Author

I pushed two more normative commits, that are oversights from the assert->with migration:

  1. Added assert as an alternative to with also in export ... from statements
  2. Removed the [no LineTerminator here] restriction before with

spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
spec.html Outdated Show resolved Hide resolved
@nicolo-ribaudo nicolo-ribaudo added has stage 4 This PR represents a proposal that has achieved stage 4, and is ready to merge. and removed pending stage 4 This proposal has not yet achieved stage 4, but may otherwise be ready to merge. labels Oct 9, 2024
@nicolo-ribaudo

This comment was marked as resolved.

@guybedford

This comment was marked as resolved.

@bakkot

This comment was marked as resolved.

@linusg
Copy link
Member

linusg commented Nov 20, 2024

What's the status of this?

@bakkot
Copy link
Contributor

bakkot commented Nov 20, 2024

@linusg It's stage 4, editors just haven't had time to get it landed yet.

@guybedford
Copy link

@bakkot thanks for the clarification - please just let us know if there's anything needed to help move this one along.

@ljharb ljharb requested a review from jmdyck January 23, 2025 20:27
Copy link
Collaborator

@jmdyck jmdyck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay to me.

(My analysis raised lots of complaints, but I think they're all false positives.)

@linusg
Copy link
Member

linusg commented Feb 13, 2025

It's now been four months since this reached stage 4 and there doesn't seem to be any movement still. Could we get an update from the editors when they plan to address this PR please?

  • It's blocking Normative: Add JSON modules #3391 which is also stage 4
  • I'm not sure about the exact cutoff date but it would be unfortunate if this doesn't make it into the ES 2025 snapshot despite being part of the language now
  • I can't speak for any other small-scale engine implementors but personally I do want to implement both of these features but not before they have been integrated to avoid potential editorial churn

I'm not bringing this up formally at the upcoming plenary but I feel like there is a discussion to be had about requiring editorial sign-off before requesting stage 4 so that PRs can be merged without further thought afterwards.

@nicolo-ribaudo
Copy link
Member Author

Note that this PR has LGTMs from Michael (#3057 (review)), Kevin (#3057 (review)) and jmdyck (#3057 (review)).

After Michael's and Kevin's LGTMs, there has been the change to delete the part about the "legacy assert keyword", so the PR needs another quick review, but it should be almost ready to land at this point.

@ljharb
Copy link
Member

ljharb commented Feb 13, 2025

@linusg the cutoff is typically based on when stage 4 was achieved, and not based on when the PR is mergeable.

@linusg
Copy link
Member

linusg commented Feb 13, 2025

That's not what I mean - there will be a snapshot of the entire spec somewhere in the Ecma archives that says "this is ECMAScript 2025". If this PR is not merged by the time that snapshot is finalized import attributes and JSON modules won't be in there, despite having achieved stage 4. I was unable to find out when that happens exactly but I'm told it's around this time of the year.

@ljharb
Copy link
Member

ljharb commented Feb 13, 2025

@linusg i'm the one who makes that snapshot, and it's never made until all outstanding stage 4 PRs are merged, so you don't have to worry about it.

@ljharb
Copy link
Member

ljharb commented Feb 13, 2025

(it's also a living standard, so nobody should be caring about the snapshots, only what's merged into github :-) )

@linusg
Copy link
Member

linusg commented Feb 13, 2025

Absolutely, I don't use these snapshots ever. Still seemed worth pointing out to avoid this situation, thanks for clarifying!

Copy link
Contributor

@syg syg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this lgtm. Some small editorial comments.

spec.html Outdated Show resolved Hide resolved
spec.html Show resolved Hide resolved
spec.html Show resolved Hide resolved
spec.html Show resolved Hide resolved
@nicolo-ribaudo
Copy link
Member Author

I rebased on main and squashed and now esmeta is complaining, I'm checking why.

@nicolo-ribaudo
Copy link
Member Author

[ParamTypeMismatch] Call[16128] argument assignment to second parameter _request_ when Call[16128] function call from Record[SourceTextModuleRecord].GetExportedNames (step 8.b, 19:43-93) to GetImportedModule
- expected: Record[ModuleRequestRecord]
- actual  : String
[ParamTypeMismatch] Call[16163] argument assignment to second parameter _request_ when Call[16163] function call from Record[SourceTextModuleRecord].ResolveExport (step 6.a.ii, 16:44-94) to GetImportedModule
- expected: Record[ModuleRequestRecord]
- actual  : String
[ParamTypeMismatch] Call[16178] argument assignment to second parameter _request_ when Call[16178] function call from Record[SourceTextModuleRecord].ResolveExport (step 9.b, 31:42-92) to GetImportedModule
- expected: Record[ModuleRequestRecord]
- actual  : String
[ParamTypeMismatch] Call[16215] argument assignment to second parameter _request_ when Call[16215] function call from Record[SourceTextModuleRecord].InitializeEnvironment (step 7.a, 13:42-93) to GetImportedModule
- expected: Record[ModuleRequestRecord]
- actual  : String

These are wrong. It thinks ExportEntry's [[ModuleRequest]] is a String, but this PR updates it to be a ModuleRequest Record.

[ParamTypeMismatch] Call[16296] argument assignment to first parameter _left_ when Call[16296] function call from FinishLoadingImportedModule (step 1.a, 3:105-151) to ModuleRequestsEqual
- expected: Record[LoadedModuleRequestRecord | ModuleRequestRecord]
- actual  : Record[{ Module : Record[ModuleRecord | ModuleRecordN], Specifier : String }]

This is also wrong. The actual type is LoadedModuleRequestRecord, declared in the line before.

[ParamTypeMismatch] Call[9455] argument assignment to first parameter _O_ when Call[9455] function call from EvaluateImportCall (step 11.d.iv.1, 28:35-54) to Get
- expected: Record[Object]
- actual  : ESValue
[ParamTypeMismatch] Call[9457] argument assignment to first parameter _O_ when Call[9457] function call from EvaluateImportCall (step 11.d.iv.2, 29:37-56) to Get
- expected: Record[Object]
- actual  : ESValue

These are because esmeta doesn't know that the entries of the list returned by EnumerableOwnProperties are arrays (thus objects).

[ReturnTypeMismatch] Block[9363] return statement in EvaluateImportCall (step 3, 4:36-73)
- expected: Normal[Record[Promise]] | Throw
- actual  : Return | Throw
[ReturnTypeMismatch] Block[9376] return statement in EvaluateImportCall (step 5.a, 7:36-71)
- expected: Normal[Record[Promise]] | Throw
- actual  : Return | Throw

This caught a bug! In case of import(yield), evaluating yield can return, thus EvaluateImportCall's type definition needs to allow Return completions.

I'll edit the PR fixing this last bug, and ignoring the other errors.

* Add Import Attributes proposal
* `npm run format`
* Updates from review
* Changes from review
* Do not re-define ImportDeclaration
* Add `assert` deprecated syntax to `export ... from`
* Remove `[no LineTerminator here]` before `with`
* Use optional symbols to reduce grammar
* Update ImportEntries and ExportEntry to use ModuleRequest Records
* Review from Michael
* Replace AttributeKey with LiteralPropertyName
* Separate ModuleRequest and LoadedModuleRequest fields
* Validate attrs when lodaing deps and not when parsing
* Merge `AssertClause` into `WithClause`, and fix missing SDOs
* Fix type annotation
* Simplify AttributesKeyword
* Reviews
* Review
* Remove support for float and bigint literal keys
* Update wording
@nicolo-ribaudo
Copy link
Member Author

nicolo-ribaudo commented Feb 14, 2025

If somebody with write access to this repo can force-push this PR to the import-attributes branch in this repo, I can rebase the json-modules PR on it.

@bakkot
Copy link
Contributor

bakkot commented Feb 15, 2025

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has stage 4 This PR represents a proposal that has achieved stage 4, and is ready to merge. has test262 tests normative change Affects behavior required to correctly evaluate some ECMAScript source text proposal This is related to a specific proposal, and will be closed/merged when the proposal reaches stage 4.
Projects
None yet
Development

Successfully merging this pull request may close these issues.