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

Symbol.prototype.valueOf.call(x) gives different results than x.valueOf() #1617

Closed
hle0 opened this issue Oct 2, 2021 · 1 comment · Fixed by #1618
Closed

Symbol.prototype.valueOf.call(x) gives different results than x.valueOf() #1617

hle0 opened this issue Oct 2, 2021 · 1 comment · Fixed by #1618
Assignees
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com
Milestone

Comments

@hle0
Copy link
Contributor

hle0 commented Oct 2, 2021

Describe the bug

Symbol gives different results depending on how valueOf is called, which causes various tests to fail, like this one for example.

Here's an example session from boa-cli:

>> a = Symbol('s')
Symbol(s)
>> Symbol.prototype.valueOf.call(a) == a.valueOf()
false
>> Symbol.prototype.valueOf.call(a) == a
false
>> a.valueOf() == a
false
>>

To Reproduce
See above. boa-cli was run with cd boa_cli; cargo run.

Expected behavior

The valueOf a Symbol should always == the Symbol, no matter how valueOf is called. Here's an example from Node.js:

> a = Symbol('s')
Symbol(s)
> a.valueOf() == a
true

This behavior should be made the same in Boa.

Build environment (please complete the following information):

  • OS: Artix Linux
  • Kernel Version: 5.13.12-artix1-1
  • Target triple: e.g. x86_64-unknown-linux-gnu
  • Rustc version: rustc 1.55.0 (c8dfcfe04 2021-09-06)

Additional context
Add any other context about the problem here.

@hle0 hle0 added the bug Something isn't working label Oct 2, 2021
@jedel1043 jedel1043 added Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com builtins PRs and Issues related to builtins/intrinsics good first issue Good for newcomers labels Oct 2, 2021
@jedel1043 jedel1043 added this to the v0.14.0 milestone Oct 2, 2021
@hle0 hle0 changed the title <type>.prototype.valueOf(x) gives different results than x.valueOf() Symbol.prototype.valueOf.call(x) gives different results than x.valueOf() Oct 3, 2021
@jedel1043
Copy link
Member

@hle0 Thank you for taking this!

JsSymbol resides on https://github.com/boa-dev/boa/blob/master/boa/src/symbol.rs, and its built-in representation on https://github.com/boa-dev/boa/blob/master/boa/src/builtins/symbol/mod.rs so these should be good starting points.

You can comment here or ping us on discord if you have any questions ☺️

hle0 added a commit to hle0/boa that referenced this issue Oct 3, 2021
hle0 added a commit to hle0/boa that referenced this issue Oct 3, 2021
Signed-off-by: hle0 <91701075+hle0@users.noreply.github.com>
hle0 added a commit to hle0/boa that referenced this issue Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics 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.

2 participants