Permalink
Browse files

Editorial: Store and rethrow module instantiation/evaluation errors

This closes #862 by ensuring that repeated calls to ModuleDeclarationInstantiation() and ModuleEvaluation(), for Source Text Module Records, rethrow any exceptions they previously threw, instead of silently succeeding. This clarifies how host environments can do top-down instantiation/evaluation of module graphs, instead of having to do bottom-up instantiation/evaluation in order to record individual failures and thus prevent future instantiation/evaluation.

For background on the trouble caused by the previous approach of silent success, see:

- whatwg/html#1545
- #862
- whatwg/html#2629
- whatwg/html#2595 (comment)

In the process, this helps formalize some of the invariants previously stated in a vague way, such as "ModuleDeclarationInstantiation must have completed successfully", replacing them instead with an explicit [[Status]] field whose contents can be asserted against. It also clarifies the relationship of Module Records that are not Source Text Module Records with respect to these invariants; in brief, they are expected to be leaves in the graph, with no descendants.

Finally, it also updates the machinery involved in module instantiation and evaluation, first by renaming the ModuleDeclarationInstantion() and ModuleEvaluation() abstract methods to Instantiate() and Evaluate(), and also by documenting all of the abstract operations and methods involved. This includes non-normative prose containing example Source Text Module Record graphs and how they are processed.

Closes #916.
  • Loading branch information...
GeorgNeis authored and bterlson committed Aug 2, 2017
1 parent e788e56 commit d0f821fcbb05471b700af5a125d30aa591895e6d
Showing with 512 additions and 101 deletions.
  1. +63 −0 img/module-graph-cycle.svg
  2. +48 −0 img/module-graph-missing.svg
  3. +56 −0 img/module-graph-simple.svg
  4. +345 −101 spec.html
@@ -0,0 +1,63 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 181 121">
<style>
rect {
fill: white;
stroke: black;
rx: 10;
ry: 10;
}

text {
dominant-baseline: central;
text-anchor: middle;
font-family: sans-serif;
}

line, path {
stroke: black;
marker-end: url(#arrowhead);
}

svg &gt; path {
fill: transparent;
}
</style>

<defs>
<marker id="arrowhead" markerWidth="10" markerHeight="10" refX="10" refY="3" orient="auto">
<path d="M0,0 L0,6 L9,3 z"></path>
</marker>
</defs>

<rect x="60.5" y="0.5" width="60" height="30"/>
<text x="90.5" y="15.5">A</text>

<rect x="0.5" y="90.5" width="60" height="30"/>
<text x="30.5" y="105.5">B</text>

<rect x="120.5" y="90.5" width="60" height="30"/>
<text x="150.5" y="105.5">C</text>

<!-- <line x1="90.5" y1="30.5" x2="30.5" y2="90.5"/> -->
<path d="M90.5 30.5 Q 70.5 70.5 30.5 90.5"/>
<line x1="90.5" y1="30.5" x2="150.5" y2="90.5"/>
<!-- <line x1="30.5" y1="90.5" x2="90.5" y2="30.5"/> -->
<path d="M30.5 90.5 Q 50.5 50.5 90.5 30.5"/>

<!--
Nodes:
A
B C
Edges:
A -> B
A -> C
B -> A
https://jsbin.com/qopeye
Tweaked to be curvier
-->
</svg>
@@ -0,0 +1,48 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 121 121">
<style>
rect {
fill: white;
stroke: black;
rx: 10;
ry: 10;
}

text {
dominant-baseline: central;
text-anchor: middle;
font-family: sans-serif;
}

line {
stroke: black;
marker-end: url(#arrowhead);
}
</style>

<defs>
<marker id="arrowhead" markerWidth="10" markerHeight="10" refX="10" refY="3" orient="auto">
<path d="M0,0 L0,6 L9,3 z"></path>
</marker>
</defs>

<rect x="60.5" y="0.5" width="60" height="30"/>
<text x="90.5" y="15.5">A</text>

<rect x="60.5" y="90.5" width="60" height="30"/>
<text x="90.5" y="105.5">???</text>

<line x1="90.5" y1="30.5" x2="90.5" y2="90.5"/>

<!--
Nodes:
A
???
Edges:
A -> ???
https://jsbin.com/qopeye
-->
</svg>
@@ -0,0 +1,56 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 121 211">
<style>
rect {
fill: white;
stroke: black;
rx: 10;
ry: 10;
}

text {
dominant-baseline: central;
text-anchor: middle;
font-family: sans-serif;
}

line {
stroke: black;
marker-end: url(#arrowhead);
}
</style>

<defs>
<marker id="arrowhead" markerWidth="10" markerHeight="10" refX="10" refY="3" orient="auto">
<path d="M0,0 L0,6 L9,3 z"></path>
</marker>
</defs>

<rect x="60.5" y="0.5" width="60" height="30"/>
<text x="90.5" y="15.5">A</text>

<rect x="60.5" y="90.5" width="60" height="30"/>
<text x="90.5" y="105.5">B</text>

<rect x="60.5" y="180.5" width="60" height="30"/>
<text x="90.5" y="195.5">C</text>

<line x1="90.5" y1="30.5" x2="90.5" y2="90.5"/>
<line x1="90.5" y1="120.5" x2="90.5" y2="180.5"/>

<!--
Nodes:
A
B
C
Edges:
A -> B
B -> C
https://jsbin.com/qopeye
-->
</svg>
Oops, something went wrong.

0 comments on commit d0f821f

Please sign in to comment.