Normative: Errored modules have an empty [[CycleRoot]]#3583
Conversation
|
Editors' call: We prefer the alternative fix at 09d32a3 for clarity, since it immediately answers the question of what [[CycleRoot]] is used for for the error case. @guybedford Can we ask a favor for you to review the alternative fix being equivalent to this one? |
|
@syg sure I'd be happy to do a careful review on this. Will aim to follow-up soon. |
|
I have left a review at 09d32a3#r167698635: 100% agreed this is a nicer approach than eagerly setting the cycle root, and more closely matches the intent. That said, while the first two assertions are well-defined semantics, for the last assertion on
|
aea09db to
09d32a3
Compare
spec.html
Outdated
| 1. If _module_.[[CycleRoot]] is not ~empty~, then | ||
| 1. Set _module_ to _module_.[[CycleRoot]]. | ||
| 1. Else, | ||
| 1. Assert: _module_.[[Status]] is ~evaluated~, _module_.[[EvaluationError]] is a throw completion ~empty~, and _module_.[[TopLevelCapability]] is not ~empty~. |
There was a problem hiding this comment.
(Guy's comment is for this line)
|
You are right, that last part is trivially false. Updated. |
393797a to
75b9cef
Compare
|
The rendered spec for this PR is available at https://tc39.es/ecma262/pr/3583. |
75b9cef to
1c9b6f2
Compare
1c9b6f2 to
939b993
Compare
…jonco Implement tc39/ecma262#3583 Diff: implement https://arai-a.github.io/ecma262-compare/?rev=939b9934b57543df47e2ab5d81a6fdf61f2dd2aa An error evaluated module can be reset to null if it is evaluated again. Differential Revision: https://phabricator.services.mozilla.com/D288147
…jonco Implement tc39/ecma262#3583 Diff: implement https://arai-a.github.io/ecma262-compare/?rev=939b9934b57543df47e2ab5d81a6fdf61f2dd2aa An error evaluated module can be reset to null if it is evaluated again. Differential Revision: https://phabricator.services.mozilla.com/D288147 UltraBlame original commit: cbd65def6bdc2cac54adfb515c9b21bc17e651db
…jonco Implement tc39/ecma262#3583 Diff: implement https://arai-a.github.io/ecma262-compare/?rev=939b9934b57543df47e2ab5d81a6fdf61f2dd2aa An error evaluated module can be reset to null if it is evaluated again. Differential Revision: https://phabricator.services.mozilla.com/D288147 UltraBlame original commit: cbd65def6bdc2cac54adfb515c9b21bc17e651db
…jonco Implement tc39/ecma262#3583 Diff: implement https://arai-a.github.io/ecma262-compare/?rev=939b9934b57543df47e2ab5d81a6fdf61f2dd2aa An error evaluated module can be reset to null if it is evaluated again. Differential Revision: https://phabricator.services.mozilla.com/D288147 UltraBlame original commit: cbd65def6bdc2cac54adfb515c9b21bc17e651db
This PR fixes #3582 by defaulting [[CycleRoot]] to the module itself in case of error.
In case the module is effectively on a cycle, this would be lying, but in practice it doesn't matter: when a module has an error, the error is immediately propagated to all its ancestors, so the real cycle root has the same error state.
I originally tried to set [[CycleRoot]] properly, which requires more complexity. This code that sets the states of the modules in stack in case of error, needs to:
While this complex approach is more correct, I discarded it because it's still not 100% correct. In this graph, assuming that E throws, we will have not traversed F at that point so we don't know that D should actually have [[CycleRoot]] set to C.

In https://github.com/nicolo-ribaudo/ecma262/tree/cycleroot-fix-ugly I have an alternative fix if you prefer, that instead of ensuring that [[CycleRoot]] is always set it acknowledges that in this specific case it will be
~empty~.