-
Notifications
You must be signed in to change notification settings - Fork 67
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
Editorial: Call GetWrappedValue with completion record's [[Value]] #332
Editorial: Call GetWrappedValue with completion record's [[Value]] #332
Conversation
There's a confusion of completion records and language values in two uses of the GetWrappedValue AO - quoting ECMA-262: Within this specification, the notation “Type(x)” is used as shorthand for “the type of x” where “type” refers to the ECMAScript language and specification types defined in this clause. [...] An Object is a language type, a completion record is a specification type. This means that the "If Type(value) is Object" path in GetWrappedValue would never be taken for these calls, even if the completion cecord's [[Value]] field is an Object. Correct this by passing result.[[Value]] instead of result (the completion record) itself.
Completion records are all implicitly and automatically unwrapped, so the explicit [[Value]] access should never be necessary. |
That's not true. This is only the case if an AO is prefixed with
The [[Value]] of Relevant snippets from ECMA-262:
|
It's quite true - see https://tc39.es/ecma262/#sec-implicit-completion-values:
|
That works for 3.1.1, but is still not quite right for 2.1:
|
Hmm - I think a return completion should still probably qualify for the intent of this, but I agree it currently does not. @tc39/ecma262-editors? |
It definitely does not currently qualify, and we are trying to move away from any implicit wrapping or unwrapping of completion records anyway, so I wouldn't want to extend the implicit unwrapping to any new cases. Best to be explicit here. |
@@ -178,7 +178,7 @@ <h1>PerformShadowRealmEval ( _sourceText_, _callerRealm_, _evalRealm_ )</h1> | |||
1. Suspend _evalContext_ and remove it from the execution context stack. | |||
1. Resume the context that is now on the top of the execution context stack as the running execution context. | |||
1. If _result_.[[Type]] is not ~normal~, throw a *TypeError* exception. | |||
1. Return ? GetWrappedValue(_callerRealm_, _result_). | |||
1. Return ? GetWrappedValue(_callerRealm_, _result_.[[Value]]). |
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. Return ? GetWrappedValue(_callerRealm_, _result_.[[Value]]). | |
1. Return ? GetWrappedValue(_callerRealm_, _result_). |
this one is still implicitly unwrapped
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.
Can be but shouldn't be. I'm just going to have to redo this change in tc39/ecma262#2547.
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.
At the moment, it should be; until that PR is merged, shouldn't proposals build off of the current spec?
Obviously if that PR is planned to be merged prior to this proposal getting stage 4, it's fine not to make the change here, but it's still worth noting that it's already correct as-is.
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.
It's correct either way.
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.
I'll accept this change as it gives me less work. The editorial direction seems clear and it's an easy fix if by any chance the referred PR fails to land.
Thanks, @linusg! |
There's a confusion of completion records and language values in two
uses of the GetWrappedValue AO - quoting ECMA-262:
An Object is a language type, a completion record is a specification
type.
This means that the "If Type(value) is Object" path in GetWrappedValue
would never be taken for these calls, even if the completion cecord's
[[Value]] field is an Object. Correct this by passing result.[[Value]]
instead of result (the completion record) itself.