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

Editorial: Using Object instead of constructor in PromiseResolve #3376

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

d01c2
Copy link
Contributor

@d01c2 d01c2 commented Jul 24, 2024

The argument C of the abstract operation PromiseResolve has type of Constructor in current spec. However, as following example, it allows an object as C and throws an error 42 in 1.a. I think the type of C should be an Object, not a constructor.

var C = {}
var x = new Promise(function () {});
Object.defineProperty(x, 'constructor', { get: () => { throw 42; }});
Promise.resolve.call(C, x);

@jmdyck
Copy link
Collaborator

jmdyck commented Jul 24, 2024

Looks correct to me.

(I was thinking that maybe PromiseResolve is right to require that _C_ be a constructor, and instead, Promise.resolve should do more strict checking before it invokes PromiseResolve, but that would be a change of behavior for your example.)

@bakkot bakkot added the ready to merge Editors believe this PR needs no further reviews, and is ready to land. label Sep 2, 2024
@ljharb ljharb merged commit 9d945cf into tc39:main Sep 2, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editorial change ready to merge Editors believe this PR needs no further reviews, and is ready to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants