Skip to content

Conversation

@nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Jan 15, 2026

Current spec:
image

Proposed spec:
image


In the current spec, the condition in step 4 can only be true if the condition in step 3 was true. Moving step 4 as a sub-step of step 3 makes it clearer, without the next reader having to wonder how we can hit the control flow path with 3 false and 4 true.

Proof:

For convenience, I'm going to call module the value that the module variable has starting from step 3.a.i/4, and originalModule the "this value" of the Evaluate() concrete method. module is either originalModule or its [[CycleRoot]].

If 4 is true, it's because module already went through step 7 of Evaluate(), since that's the only place where [[TopLevelCapability]] is set. This means that module.[[Status]] is either already ~evaluated~ (asserted in steps 9.b and 10.a) or (~evaluating-async~).

originalModule was in that previous call either module itself, or part of a cycle containing both. A cycle transitions to ~evaluated~/~evaluating-async~ atomically (steps 16.b.v and 16.b.vi of InnerModuleEvaluation), which means that originalModule is also either evaluated or evaluating-async.

Thus if 4 is true, 3 must have been true.

@github-actions
Copy link

The rendered spec for this PR is available at https://tc39.es/ecma262/pr/3742.

Copy link
Member

@linusg linusg left a comment

Choose a reason for hiding this comment

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

Reasoning seems correct to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants