Closed dandclark closed 3 years ago
No concerns if you throw. Problems around polluting the value via prototype aren't possible.
On Thu, Apr 29, 2021, 6:19 PM Dan Clark @.***> wrote:
@.**** commented on this pull request.
In spec.html https://github.com/tc39/proposal-import-assertions/pull/108#discussion_r623473931 :
- If Type(arg) is not Object, then
- Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
This was discussed in April's meeting and it seems like there was pretty broad agreement that throwing for non-Object, rather than converting ToObject, is the direction we want to go. This matches what ECMA 402 is doing with GetOption() (link https://github.com/tc39/notes/blob/master/meetings/2020-09/sept-22.md#getoption-in-ecma-262 ).
@bmeck https://github.com/bmeck you mentioned that you had varied opinions on whether to reject or not based on whether we pull off the prototype (or something along those lines -- I didn't quite follow at the time). You said that you wanted to follow up offline, so I wanted to give you a chance to chime in here in case there was any concern you wanted to raise before I go ahead and land this PR.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tc39/proposal-import-assertions/pull/108#discussion_r623473931, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABZJI33CYAGD3SRAVVG353TLHSRJANCNFSM4V77TAQA .
In the Runtime Semantics for the version of dynamic import() that takes an assertions argument, the second
argRef
and theassertionsObj
are not guaranteed to be Objects. e.g:But, Get() and EnumerableOwnPropertyNames both assert that the argument to them is an Object.
This change adds checks that these are of Type Object, and reject the promise with a TypeError if either is not.
assertionsObj
is still allowed to be undefined. This will be useful if we use the options bag for other things such as evaluator attributes, where a missingassertionsObj
shouldn't result in failure: