A record of the branch proposal-defer-import-eval · site/proposal-defer-import-eval.json
Applying a proposal
What it takes to apply a TC39 proposal to this specification, shown on tc39/proposal-defer-import-eval: the text merged, what was written by hand, what was regenerated, what the merge found, and the results.
What was done
The proposal tc39/proposal-defer-import-eval, at its commit 6fefd29, was applied to ECMA-262 at b1eaed82f in a branch of this repository, proposal-defer-import-eval (from main): the proposal's text merged into the specification's, the Lean specification regenerated from the result, the engine built and its claims checked, and the proposal's test262 tests run.
- 228lines written by hand, in 19 files: the pin, 10 answers to the merge, 14 readings, list files and tests
- 0files of hand-written Lean changed
- 251of the proposal's 252 test262 tests (
import-defer) pass; 1 not run, none fails
How a proposal is applied
- Pin it. The proposal's repository is a submodule,
external/proposal-defer-import-eval, at6fefd29, and one line ofspec/proposals.txtnames it with its answers file. - Merge it.
scripts/apply_proposal.pyreads the proposal'sspec.emuas a diff against ECMA-262: it matches each clause by itsidand each block of the clause by its old text (the block with its<ins>dropped and its<del>kept), which must be the base's; it inserts the proposal's new clauses and removes the ones it deletes. Where the old text is not the base's, or an inserted block's place is not shown, it refuses and asks: the answers file (spec/proposals/defer-import-eval/resolutions.txt) answers each question, one line each. - The text.
scripts/spec_text.pymakes the text every generator, check and page reads: ECMA-262 with the proposals ofspec/proposals.txtapplied, remade whenever an input changes. - Readings. A sentence of the proposal that the generator cannot read as it stands gets a reading in the overlay, as any sentence of ECMA-262 does.
- Regenerate.
python3 scripts/gen_spec.py --write --gen target/release/spec-genandpython3 scripts/jsgrammar.py --write --gen target/release/jsgrammar --readings spec/formal/readings.emu --readings spec/formal/syntax.emu --json spec/formal/json.emuwritelean/Ecma/Gen,lean/Ecma/Grammar/Genand their id tables from the text (python3 scripts/spec_text.py --reportsays what the merge did). - Build and check.
lake build, the axiom check of the claims,python3 scripts/quick_check.py, and test262 with the proposal's feature no longer in[skip-features].
What was written by hand
| File | Added | Removed |
|---|---|---|
.gitmodules | +3 | −0 |
external/proposal-defer-import-eval (new) | +1 | −0 |
spec/proposals.txt | +2 | −0 |
spec/proposals/defer-import-eval/README.md (new) | +25 | −0 |
spec/proposals/defer-import-eval/resolutions.txt (new) | +27 | −0 |
spec/formal/defer-import.emu (new) | +102 | −0 |
spec/formal/fields.emu | +1 | −1 |
spec/formal/lists.emu | +4 | −4 |
spec/formal/permanent.emu | +0 | −1 |
spec/formal/realm.emu | +2 | −3 |
spec/formal/decisions.md | +31 | −0 |
spec/formal/phrase-unreviewed.txt | +9 | −1 |
spec/formal/readings-restating.txt | +11 | −3 |
tests/run/frontend_not_ecmascript.js | +3 | −2 |
tests/run/import_defer_basic.js | +3 | −6 |
tests/run/import_defer_dynamic.js | +2 | −5 |
tests/run/import_defer_tla.js | +3 | −6 |
tests/test262/full.conf | +0 | −1 |
tests/test262/sample.conf | +0 | −1 |
tests/test262/suite.conf | +0 | −1 |
Hand-written Lean: 0 files changed under lean/ outside its generated directories.
The answers to the merge (10)
| Answer | The question the merge asked | Why this answer |
|---|---|---|
ignore sec-LoadRequestedModules 1 | the clause's header (<dl class="header">) has no markup but is not the base's | the proposal abbreviates it: it drops the <dt>description</dt> (and, in InnerModuleLoading and InnerModuleLinking, every entry). It changes nothing there, so the base's header stays |
ignore sec-InnerModuleLoading 1 | the clause's header (<dl class="header">) has no markup but is not the base's | the proposal abbreviates it: it drops the <dt>description</dt> (and, in InnerModuleLoading and InnerModuleLinking, every entry). It changes nothing there, so the base's header stays |
ignore sec-moduledeclarationlinking 1 | the clause's header (<dl class="header">) has no markup but is not the base's | the proposal abbreviates it: it drops the <dt>description</dt> (and, in InnerModuleLoading and InnerModuleLinking, every entry). It changes nothing there, so the base's header stays |
ignore sec-InnerModuleLinking 1 | the clause's header (<dl class="header">) has no markup but is not the base's | the proposal abbreviates it: it drops the <dt>description</dt> (and, in InnerModuleLoading and InnerModuleLinking, every entry). It changes nothing there, so the base's header stays |
place sec-InnerModuleLoading 2 after 2 | the proposal inserts a note (<emu-note> all <ins>) but omits the header and the algorithm around it: before or after the algorithm? | after it (base block 2 is the algorithm): a note on an algorithm follows it, as everywhere in the text, and the note speaks of the algorithm's steps |
place sec-InnerModuleLinking 2 after 2 | the proposal inserts a note (<emu-note> all <ins>) but omits the header and the algorithm around it: before or after the algorithm? | after it (base block 2 is the algorithm): a note on an algorithm follows it, as everywhere in the text, and the note speaks of the algorithm's steps |
rebase sec-source-text-module-record-initialize-environment 2 | InitializeEnvironment's steps: the proposal's old text lacks two of the base's lines, Assert: _exportEntry_.[[ExportName]] is not *null*. (1.a) and Assert: _importEntry_.[[ImportName]] is a String. (7.c.i) | the base is newer than the proposal's copy; the proposal's changes (GetModuleNamespace's new phase argument, twice, and the ~deferred-namespace~ branch of 7.c.iii) touch other lines, so the three-way merge applies them to the base with no conflict and both Asserts stay |
rebase sec-resolveexport 2 | ResolveExport's steps: the proposal's old text has an Else, after Return ResolvedBinding Record { … ~namespace~ }. that the base no longer has | the same: the base dropped it, the proposal's change (the ~deferred-namespace~ branch) is elsewhere in the algorithm, and the merge applies it to the base's lines |
rebase-take sec-abstract-module-records 4 | Module Record Fields: the table differs as a whole (the base gained a <thead>), and row by row too, at [[Namespace]]'s Meaning | the proposal rewrote that cell without <ins>/<del>: the link to #sec-module-namespace-objects (a clause it deletes) becomes #sec-module-namespace-exotic-objects, and "whose [[Deferred]] slot is false," is added. That is the proposal's change, so its line wins where it differs from the base; the base's <thead> stays. |
rename ModuleRequestsEqual ModuleRequestsKeyEqual | a warning: ModuleRequestsEqual, whose clause the proposal removes (del-sec-ModuleRequestsEqual), is still used in 6 clauses the proposal does not show | the proposal's new clause ModuleRequestsKeyEqual takes over the old one's id (oldids="sec-ModuleRequestsEqual"), with the same steps, and the proposal renames the two uses it shows; the other seven uses (Realm Record and Script Record [[LoadedModules]], Cyclic Module Record [[LoadedModules]], InnerModuleLoading 2.d.ii, GetImportedModule 1, HostLoadImportedModule's requirements) are renamed with it. |
The readings (14)
Each reading says what a sentence of the proposal means, in the notation the generator reads: 10 new, 3 re-anchored, 1 replaced. The proposal's sentence is quoted from the merged text, found by the hash the overlay records; the reasons are the branch's report's.
| Clause, step | The proposal's sentence, as the merged text has it | The reading |
|---|---|---|
| 10.4.6.6 [[DefineOwnProperty]], step 1 new | If IsSymbolLikeNamespaceKey(propertyKey, obj), return ! OrdinaryDefineOwnProperty(obj, propertyKey, propertyDesc). |
|
| Why the generator could not read it unaided: a Boolean call used bare as a condition. ECMA-262 never writes one, so the notation has no such form | ||
| 10.4.6.7 [[HasProperty]], step 1 new | If IsSymbolLikeNamespaceKey(propertyKey, obj), return ! OrdinaryHasProperty(obj, propertyKey). |
|
| Why the generator could not read it unaided: a Boolean call used bare as a condition. ECMA-262 never writes one, so the notation has no such form | ||
| 10.4.6.8 [[Get]], step 1 new | If IsSymbolLikeNamespaceKey(propertyKey, obj), then |
|
| Why the generator could not read it unaided: a Boolean call used bare as a condition. ECMA-262 never writes one, so the notation has no such form | ||
| 10.4.6.10 [[Delete]], step 1 new | If IsSymbolLikeNamespaceKey(propertyKey, obj), then |
|
| Why the generator could not read it unaided: a Boolean call used bare as a condition. ECMA-262 never writes one, so the notation has no such form | ||
| 16.2.1.5.1.2 ReadyForSyncExecution, step 5 new | If IsModuleSCCEvaluated(module), return true. |
|
| Why the generator could not read it unaided: a Boolean call used bare as a condition. ECMA-262 never writes one, so the notation has no such form | ||
| 16.2.1.13 GetModuleNamespace, step 2 new | If phase is defer, let namespace be module.[[DeferredNamespace]]. Else, let namespace be module.[[Namespace]]. |
|
| Why the generator could not read it unaided: an inline conditional written as two sentences. The text writes "…; else let …" everywhere else | ||
| 13.3.10.5 ContinueDynamicImport, step 6.d.iv new | For each Module Record dep of evaluationList, append dep.Evaluate() to asyncDepsEvaluationPromises. |
|
| Why the generator could not read it unaided: a For each with an inline body, which the text writes nowhere else | ||
| 16.2.1.6.1.3 Evaluate, step 1 new | Assert: None of module or any of its recursive dependencies have [[Status]] set to evaluating, linking, unlinked, or new. |
|
| Why the generator could not read it unaided: "recursive dependencies" is defined nowhere. There is no model operation for it, so this is the one new loop | ||
| 16.2.1.9 GetImportedModule, step 1 re-anchored | Let records be a List consisting of each LoadedModuleRequest Record r of referrer.[[LoadedModules]] such that ModuleRequestsKeyEqual(r, request) is true. |
|
| Why the generator could not read it unaided: the rename changed the step's hash, so the reading lost its anchor | ||
| 13.3.10.4 EvaluateImportCall, step 9.f re-anchored | Sort attrs according to the lexicographic order of their [[Key]] field, treating the value of each such field as a sequence of UTF-16 code unit values. NOTE: This sorting is observable only in that hosts are prohibited from changing behaviour based on the order in which attributes are enumerated. |
|
| Why the generator could not read it unaided: the step was renumbered | ||
| 16.2.1.6.1.3.1 InnerModuleEvaluation, step 18.b.iv re-anchored | Assert: requiredModule.[[AsyncEvaluationOrder]] is either an integer or unset. |
|
| Why the generator could not read it unaided: the step was renumbered | ||
| 10.4.6.12 ModuleNamespaceCreate, step 9 replaced | Create an own data property of namespace named %Symbol.toStringTag% whose [[Value]] is toStringTag and whose [[Writable]], [[Enumerable]], and [[Configurable]] attributes are false. |
|
| Why the generator could not read it unaided: the old reading created the properties of §28.3, which the proposal deletes; the new sentence has no phrase ("CreateOwnProperty, unclassified") | ||
| 8.2.1 BoundNames new | No row for |
|
| Why the generator could not read it unaided: the proposal's text does not give it; the reading gives what test262's tests of the proposal require | ||
| 16.2.1.8.1 CreateDefaultExportSyntheticModule, step 3 new | Return the Synthetic Module Record { [[Realm]]: realm, [[Environment]]: empty, [[Namespace]]: empty, [[HostDefined]]: undefined, [[ExportNames]]: « "default" », [[EvaluationSteps]]: setDefaultExport }. |
|
| Why the generator could not read it unaided: the proposal's text does not give it; the reading gives what test262's tests of the proposal require | ||
Other changes to the overlay:
spec/formal/fields.emu: removed[[BindingName]]: a String or ~namespace~; added[[BindingName]]: a String, ~namespace~, or ~deferred-namespace~spec/formal/permanent.emu: removed<emu-permanent clause="sec-moduleevaluation" step="1" class="assert-provenance">About the surrounding agent's other calls to Evaluate, which the state at the step does not record.</emu-permanent>
What regenerating changed
18 generated modules, +1,555 −1,106 lines, nobody edited:
| Directory | Modules | Added | Removed | Modules |
|---|---|---|---|---|
lean/Ecma/Gen | 13 | +1,197 | −775 | Decls, Phrases, Phrases_DeferImport (new), Realm, S10_4_part2, S13_3, S16_2_part1, S16_2_part2, S16_2_part3, S27_5_part1, S27_5_part2, Tables_1, Tables_2 |
lean/Ecma/Grammar/Gen | 5 | +358 | −331 | Index, Symbols, Syntactic1, Syntactic2, SyntacticProd |
The id tables only gained lines, retired lines, or gave a kept number a new name; no number moved:
| Table | New | Retired | Renamed |
|---|---|---|---|
clause-ids.txt | 11 | 2 | 1 |
enum-ids.txt | 3 | 0 | 0 |
erratum-ids.txt | 13 | 3 | 0 |
field-ids.txt | 3 | 0 | 0 |
nt-ids.txt | 1 | 0 | 0 |
prod-ids.txt | 8 | 4 | 0 |
sdo-ids.txt | 2 | 0 | 0 |
table-ids.txt | 5 | 0 | 0 |
Because every number the generated data uses is kept (How it works), the regenerated modules differ only where the proposal changes the text, and every proof that names an algorithm by its number still names the same algorithm.
What the merge found in the proposal's text
Run with no answers, the merge refuses 9 times and warns 1 time. The refusals, by what the answer found them to be:
| Refusal | Count |
|---|---|
| a context block that is not the base's (an abbreviated header) | 4 |
| an inserted block whose place is not shown | 2 |
| old text that is not the base's: the base changed after the proposal was written | 2 |
| old text that is not the base's: the proposal changed it without marking it | 1 |
The warning: ModuleRequestsEqual (sec-ModuleRequestsEqual, removed (sec-ModuleRequestsEqual)) is still used in 6 clause(s): sec-GetImportedModule, sec-HostLoadImportedModule, sec-InnerModuleLoading, sec-code-realms, sec-cyclic-module-records, sec-script-records; answer with `rename ModuleRequestsEqual NEW` if the proposal renames it.
With the answers, it changes 26 clauses, inserts 11, removes 2 and copies 3 figures; every one of the proposal's 129 <ins> texts is in the result, none of its 57 <del> texts is left, and the clause tree is the base's less the removed clauses plus the inserted ones.
For the merge to ask nothing, a proposal's text would reproduce whole blocks (no abbreviated headers; an inserted note shown with the algorithm before it), be written against the current ECMA-262, mark every change with <ins> and <del>, and rename a removed operation at every call or say that the rest are renamed with it.
The results
test262. The 252 tests of the feature import-defer at test262 2e58f87d8: 251 pass, 1 skip (not run: language/import/import-defer/evaluation-triggers/ignore-private-name-access.js, feature nonextensible-applies-to-private).
| Directory | Pass | Not passing | Skipped |
|---|---|---|---|
language/expressions/assignmenttargettype | 2 | ||
language/expressions/dynamic-import | 147 | ||
language/import/import-defer | 102 | 1 |
The claims. On the branch, Engine.implements and Engine.run_sound rest on propext, Classical.choice, Quot.sound alone (no native_decide pins); the same list as without the proposal.
The programs. Each of the proposal's three example programs, under the proposal's build and under the specification's (both checked when this site was built):
| Program | With the proposal | The specification |
|---|---|---|
tests/run/import_defer_basic.js | normal: undefined[object Deferred Module]main starts; heavy evaluates; read 42; read again 42 | throw: SyntaxError |
tests/run/import_defer_dynamic.js | normal: undefinedpromise settled; then in ns: false; dep evaluates; x is 1 | throw: SyntaxError |
tests/run/import_defer_tla.js | normal: undefinedbefore access: b, e, d, aafter access: b, e, d, a, f, c | throw: SyntaxError |
Try it
The debugger has the proposal's build: under it each program runs and pauses in the proposal's algorithms; under the specification's it is a SyntaxError.
import defer: a namespace evaluated at its first read
Open in the debugger: Proposal (Stage 3): import defer Open in the debugger: The specification
import.defer(): a promise for an unevaluated namespace
Open in the debugger: Proposal (Stage 3): import defer Open in the debugger: The specification
import defer and top-level await
Open in the debugger: Proposal (Stage 3): import defer Open in the debugger: The specification