Re: [w3ctag/design-reviews] Realms API ECMAScript Proposal (#542)

In this example, `new Foo(1)` will throw a TypeError because it would return an object. The API code just checks for an existing `[[Call]]` internal and that means the Realms can still receive a constructor, but won't be able to fully use it, like `Array` as in:

```js
const rArray = realm.evaluate('Array');
try {
  rArray(); // would return a new Array from the other realm
} catch(e) {
  e.constructor === TypeError;
}
```

This happens because the low level code abstraction just observes the existence of a `[[Call]]` internal in the given object, and it does not create distinction for special cases.

There is a curiosity for this case using `new Foo(1)`. Here, `Foo` is a wrapped exotic in the main realm and it doesn't have a `[[Construct]]` internal. The _new Expression_ will throw a TypeError before even internally accessing the wrapped function because of the exotic is not a valid constructor.



-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/542#issuecomment-840933105

Received on Friday, 14 May 2021 01:23:56 UTC