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

Set and Map can be created without new #894

Closed
twop opened this issue May 13, 2021 · 0 comments · Fixed by #895
Closed

Set and Map can be created without new #894

twop opened this issue May 13, 2021 · 0 comments · Fixed by #895

Comments

@twop
Copy link
Contributor

twop commented May 13, 2021

found out while working on Promises fixing this test: https://github.com/tc39/test262/blob/main/test/built-ins/Promise/undefined-newtarget.js

relevant snippet:

var p = new Promise(function() {});
assert.throws(TypeError, function() {
  Promise.call(p, function() {});
});

as it turned out the same applies for Map and Set (and possibly other built-ins).
this snippet should throw a type error

const m = new Map();
Map.call(m,[]);
// TypeError: Constructor Map requires 'new'

but works fine in Jint.

My understanding that Call method should just always throw, like so:

public override JsValue Call(JsValue thisObject, JsValue[] arguments)
{ 
     return ExceptionHelper.ThrowTypeError<JsValue>(_engine, "Constructor Map requires 'new'");
}
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 a pull request may close this issue.

1 participant