-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Ensure all evaluated modules have a [[CycleRoot]] #3583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Guy's comment is for this line)
You are right, that last part is trivially false. Updated. |
1. If _module_.[[CycleRoot]] is not ~empty~, then | ||
1. Set _module_ to _module_.[[CycleRoot]]. | ||
1. Else, | ||
1. Assert: _module_.[[Status]] is ~evaluated~ and _module_.[[EvaluationError]] is a throw completion ~empty~. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Assert: _module_.[[Status]] is ~evaluated~ and _module_.[[EvaluationError]] is a throw completion ~empty~. | |
1. Assert: _module_.[[Status]] is ~evaluated~ and _module_.[[EvaluationError]] is a throw completion. |
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~
.