Skip to content
This repository has been archived by the owner on Aug 29, 2021. It is now read-only.

stackErrorCapability in "evaluating" case #48

Closed
GeorgNeis opened this issue Feb 19, 2019 · 2 comments
Closed

stackErrorCapability in "evaluating" case #48

GeorgNeis opened this issue Feb 19, 2019 · 2 comments

Comments

@GeorgNeis
Copy link

As discussed with Dan, step 13g of InnerModuleEvaluation (in https://github.com/guybedford/proposal-top-level-await/tree/promise-refactoring) doesn't make sense:

If requiredModule.[[Status]] is "evaluating", then
- Assert: requiredModule is a Source Text Module Record.
- Set module.[[DFSAncestorIndex]] to min(module.[[DFSAncestorIndex]], requiredModule.[[DFSAncestorIndex]]).
- Let stackErrorCapability be ! NewPromiseCapability(%Promise%).
- Perform ! PerformPromiseThen(requiredModule.[[ExecPromise]], undefined, stackErrorCapability.[[Reject]]).
- Add stackErrorCapability to the list dependencyExecPromises.

stackErrorCapability will never be fulfilled, so module will never get executed. The last three steps should probably be dropped entirely.

@littledan
Copy link
Member

If we go with synchronous execution as our resolution to #43, we probably would just restore the old error handling text instead of these weird lines.

littledan added a commit to littledan/proposal-top-level-await that referenced this issue Feb 22, 2019
littledan added a commit to littledan/proposal-top-level-await that referenced this issue Feb 22, 2019
littledan added a commit to littledan/proposal-top-level-await that referenced this issue Feb 22, 2019
@littledan
Copy link
Member

Fixed in #51 (and there's no need to revert this part).

littledan added a commit to littledan/proposal-top-level-await that referenced this issue Mar 1, 2019
littledan added a commit to littledan/proposal-top-level-await that referenced this issue Mar 1, 2019
littledan added a commit to littledan/proposal-top-level-await that referenced this issue Mar 19, 2019
This patch is a variant on tc39#49 which determines which module subgraphs
are to be executed synchronously based on syntax (whether the module
contains a top-level await syntactically) and the dependency graph
(whether it imports a module which contains a top-level await,
recursively). This fixed check is designed to be more predictable and
analyzable.

Abstract module record changes:
- The [[Async]] field stores whether this module or dependencies are
  async. It is expected to be initialized by the Linking phase.
- The [[ExecutionPromise]] field stores the Promise related to the
  evaluation of a module whose [[Async]] field is *true*.
- Evaluate() returns a Promise for [[Async]] modules, a completion
  record for sync modules which throw, or undefined otherwise.

Cyclic Module Record changes:
- A new [[ModuleAsync]] field stores whether this particular module
  is asynchronous (dependencies aside).
- The ExecuteModule method on Cyclic Module Records takes an
  argument for the Promise capability, but only if that particular
  module is [[ModuleAsync]].
- The Link/Instantiate phase is used to propagate the [[Async]]
  field up the module graph to dependencies.
- When there's a cycle, with some modules sync and some async, the
  whole cycle is considered async, with the Promise of each module
  set to the entrypoint of the cycle, although the cycle-closing
  edge will not actually be awaited (since this would be a deadlock).

Source Text Module Record changes:
- The check for whether a module contains a top-level await locally
  is in a ContainsAwait algorithm (TBD writing this out, but it
  should be static since await may not appear in a direct eval)
- Module execution works as before if ContainsAwait is false, and
  works like an async function if ContainsAwait is true.

Closes tc39#47, tc39#48, tc39#43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants