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

An issue about evaluating instanceof #6507

Open
NWU-NISL opened this issue Sep 25, 2020 · 1 comment
Open

An issue about evaluating instanceof #6507

NWU-NISL opened this issue Sep 25, 2020 · 1 comment

Comments

@NWU-NISL
Copy link

@NWU-NISL NWU-NISL commented Sep 25, 2020

According to ES10.0, If an object does not define or inherit @@hasInstance it uses the default instanceof semantics. When changing the value of __proto__ of an object into String, the algorithm to be used will be Function.prototype [ @@hasInstance ] instead of the default semantics. So the output of the testcase below is false as other engines do. This may be an issue of chakra.

version

v1.11.19

command

 chakra/cc_linux_x64_1_11_19/ChakraCoreFiles/bin/ch testcase.js

testcase

var  obj = {__proto__:String};
var result = "hello" instanceof obj;
print(result);

output

TypeError: obj is not a function. (evaluating '"hello" instanceof obj')

expected output

false

contributor:@YuanWangC

@rhuanjl
Copy link
Collaborator

@rhuanjl rhuanjl commented Dec 16, 2020

This Bug would be a good first issue for a new or beginning contributor to dig into, would need to investigate JavascriptOperators::OP_IsInst and see how/through what path it can fail to check prototypes for an @@hasInstance tag.

Also whilst doing it the switch IsES6HasInstanceEnabled which appears there should be removed from the codebase - check #6415 for info on removing switches.

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

Successfully merging a pull request may close this issue.

None yet
2 participants