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

Calling "new" on a primitive value does not throw an error #801

Closed
dapper-gh opened this issue Oct 5, 2020 · 2 comments · Fixed by #825
Closed

Calling "new" on a primitive value does not throw an error #801

dapper-gh opened this issue Oct 5, 2020 · 2 comments · Fixed by #825
Assignees
Labels
bug Something isn't working E-Easy Easy execution Issues or PRs related to code execution good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com

Comments

@dapper-gh
Copy link

Describe the bug
Calling new on a primitive value (or, in other words, calling a primitive value as a constructor) does not error.

To Reproduce

const a = "";
new a();

Expected behavior
A TypeError is supposed to be raised. The spec can be found here (step 7). Chrome implements this properly:
image

Build environment (please complete the following information):

  • OS: Windows 10
  • Version: Version 1909 (OS Build 18363.1082)
  • Target triple: x86_64-pc-windows-msvc
  • Rustc version: rustc 1.46.0 (04488afe3 2020-08-24)

Additional context
MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new
Spec: https://tc39.es/ecma262/#sec-evaluatenew

@dapper-gh dapper-gh added the bug Something isn't working label Oct 5, 2020
@HalidOdat HalidOdat added the execution Issues or PRs related to code execution label Oct 5, 2020
@HalidOdat
Copy link
Member

The problem is here boa/src/syntax/ast/node/new/mod.rs:58 we should throw a TypeError (with .throw_type_error()), but instead we are returning undefined

@HalidOdat HalidOdat added E-Easy Easy good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com labels Oct 5, 2020
@dlemel8
Copy link
Contributor

dlemel8 commented Oct 6, 2020

Hey @HalidOdat , I want to do this.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working E-Easy Easy execution Issues or PRs related to code execution good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants