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: Fix parameter type of the OrdinaryCreateFromConstructor #3436

Closed

Conversation

kimjg1119
Copy link
Contributor

In OrdinaryCreateFromConstructor, the constructor parameter is currently expected to be a constructor.
However, the following code demonstrates that a function object can also be passed as the parameter(Specifically, the problem is from the EvaluateGeneratorBody).

function *f() {} f();
async function *f() {} f();
ESMeta log

Running ESMeta in dev branch reproduces the result below.

[ParamTypeMismatch] Call[13531] argument assignment to first parameter _constructor_ when Call[13508] function call from GeneratorBody[0,0].EvaluateGeneratorBody (step 2, 3:25-183) to OrdinaryCreateFromConstructor
- expected: Record[Constructor]
- actual  : Record[ECMAScriptFunctionObject]

[ParamTypeMismatch] Call[13809] argument assignment to first parameter _constructor_ when Call[13786] function call from AsyncGeneratorBody[0,0].EvaluateAsyncGeneratorBody (step 2, 3:33-231) to OrdinaryCreateFromConstructor
- expected: Record[Constructor]
- actual  : Record[ECMAScriptFunctionObject]

Since changing the type from a constructor to a function object does not introduce any breaks, I propose broadening the parameter type for now. This change would also align with GetPrototypeFromConstructor.

However, further discussion may needed because, given the current parameter names and descriptions, it is unclear whether these functions are intended to accept a function object rather than just a constructor.

@bakkot
Copy link
Contributor

bakkot commented Oct 2, 2024

Thanks for filing. I'm closing as a duplicate of #3287; apologies for having left that open for so long.

@bakkot bakkot closed this Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants