From 57372821cacdb1cdefdcaf8278c2f4159cd4e320 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Thu, 7 Sep 2017 21:04:51 -0400 Subject: [PATCH] Separate out parse error and error to rethrow --- source | 84 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/source b/source index 0322e34e8b1..a3d8a24cead 100644 --- a/source +++ b/source @@ -86259,16 +86259,23 @@ interface NavigatorOnLine { script">module scripts; or null. In the former two cases, it represents a parsed script; null represents a failure parsing.

-
An error
+
A parse + error
+ +

A JavaScript value, which has meaning only if the record is null, indicating that the corresponding script + source text could not be parsed.

+ +
An error + to rethrow

A JavaScript value representing an error that will prevent evaluation from succeeding. It will be re-thrown by any attempts to run the script.

There are two main categories of such errors: errors parsing the script's source - text, in which case the script's record will - be null; or more general errors in dependencies of a module script. This - distinction is used by the algorithm for finding the first parse error.

+ text (equal to the script's parse error), or + more general errors in dependencies of a module script.

Since this exception value is provided by the JavaScript specification, we know that it is never null, so we use null to signal that no error has occurred.

@@ -86965,11 +86972,7 @@ interface NavigatorOnLine {
  • Let parse error be the result of finding the first parse error given result.

  • -
  • If parse error is not null, then set result's error to parse error.

  • - -
  • -

    Otherwise:

    +
  • If parse error is null, then:

    1. Let record be result's NavigatorOnLine {

    2. Perform record.Instantiate().

      -

      This step will recursively call Instantiate - on all of the module's uninstantiated dependencies.

      +

      This step will recursively call Instantiate on all of the module's uninstantiated + dependencies.

      If this throws an exception, set result's error to that exception.

      + data-x="concept-script-error-to-rethrow">error to rethrow to that exception.

  • +
  • Otherwise, set result's error to + rethrow to parse error.

  • +
  • Asynchronously complete this algorithm with result.

  • @@ -87002,17 +87009,9 @@ interface NavigatorOnLine {
  • Append moduleScript to discoveredSet.

  • -
  • -

    If moduleScript's record is null, - then return moduleScript's error.

    - -

    It's important that we check if moduleScript's record is null, and not simply check that - moduleScript's error is non-null. This - ensures we only catch errors from parsing moduleScript, and not instantiation errors - or errors from parsing its dependencies that were stored in the error field for later re-throwing.

    -
  • +
  • If moduleScript's record is null, + then return moduleScript's parse + error.

  • Let childSpecifiers be the value of moduleScript's record's [[RequestedModules]] internal slot.

  • @@ -87069,6 +87068,9 @@ interface NavigatorOnLine {
  • Set script's muted errors to muted errors.

  • +
  • Set script's parse error and + error to rethrow to null.

  • +
  • Let result be ParseScript(source, settings's Realm, @@ -87078,11 +87080,12 @@ interface NavigatorOnLine { result.[[HostDefined]] will be script.

  • -
  • If result is a List of errors, then set script's error to result[0].

  • +
  • If result is a list of errors, then set script's parse error and its error to rethrow to result[0].

  • Otherwise, set script's record to - result and its error to null.

  • + result.

  • Return script.

  • @@ -87105,6 +87108,9 @@ interface NavigatorOnLine {
  • Set script's settings object to settings.

  • +
  • Set script's parse error and + error to rethrow to null.

  • +
  • Let result be ParseModule(source, settings's Realm, @@ -87115,10 +87121,11 @@ interface NavigatorOnLine {

  • -

    If result is a List of errors, then:

    +

    If result is a list of errors, then:

      -
    1. Set script's error to +

    2. Set script's parse error and + its error to rethrow to result[0].

    3. Return script.

    4. @@ -87139,7 +87146,8 @@ interface NavigatorOnLine {
      1. Let error be a new TypeError exception.

      2. -
      3. Set script's error to +

      4. Set script's parse error + and its error to rethrow to error.

      5. Return script.

      6. @@ -87156,8 +87164,6 @@ interface NavigatorOnLine {
      7. Set script's record to result.

      8. -
      9. Set script's error to null.

      10. -
      11. Set script's base URL to baseURL.

      12. @@ -87190,10 +87196,10 @@ interface NavigatorOnLine {
      13. Let evaluationStatus be null.

      14. -
      15. If script's error is not - null, then set evaluationStatus to Completion { [[Type]]: throw, [[Value]]: - script's error, [[Target]]: empty - }.

      16. +
      17. If script's error to + rethrow is not null, then set evaluationStatus to Completion { [[Type]]: throw, + [[Value]]: script's error to + rethrow, [[Target]]: empty }.

      18. Otherwise, set evaluationStatus to NavigatorOnLine {

      19. Let evaluationStatus be null.

      20. -
      21. If script's error is not - null, then set evaluationStatus to Completion { [[Type]]: throw, [[Value]]: - script's error, [[Target]]: empty - }.

      22. +
      23. If script's error to + rethrow is not null, then set evaluationStatus to Completion { [[Type]]: throw, + [[Value]]: script's error to + rethrow, [[Target]]: empty }.

      24. Otherwise: