Skip to content
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

Create new objects with a Realm #793

Open
a-sully opened this issue Nov 22, 2024 · 2 comments
Open

Create new objects with a Realm #793

a-sully opened this issue Nov 22, 2024 · 2 comments

Comments

@a-sully
Copy link
Contributor

a-sully commented Nov 22, 2024

From #787 (comment). For example, we need to do this everywhere:

-Let p be a new promise.
+Let p be a new promise in |realm|.
@inexorabletash
Copy link
Member

Any time we do "a new Thing" or implicitly create a new object (like "return a TypeError" or "reject promise with...") from "in parallel" steps, steps queued against another task source, or timeline, then we absolutely need to specify the realm. Examples in the current spec where that isn't done include:

  • createContext() - ".. .then queue an ML task with global to reject promise with a "NotSupportedError" DOMException ..."
  • build() - "... then queue an ML task with global to reject promise with an "OperationError" DOMException ..."

I'm less clear about instances where an exception is thrown or promise is rejected with a new exception during synchronous steps of a method. e.g. in Web IDL it says "When an algorithm says to throw a SomethingError then this means to construct a new JavaScript SomethingError object in the current realm and to throw it, just as the algorithms in ECMA-262 do."

That implies that we can infer the realm in simple cases. Certainly, lots and lots of specs use realms sparingly, even when they do use them for more interesting cases. Perhaps that's just a lack of rigor, though. We should ask around.

@a-sully a-sully changed the title Create promises with a Realm Create new objects with a Realm Nov 23, 2024
@a-sully
Copy link
Contributor Author

a-sully commented Nov 23, 2024

Any time we do "a new Thing" or implicitly create a new object

Updated the title and description to reflect this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants