-
Notifications
You must be signed in to change notification settings - Fork 1.2k
An issue about the Math.max(). #6519
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
Comments
@ppenzin Hello, I would like to contribute to this project solving this issue. I'm working on it :D |
@ppenzin Where I can fine the definition of the Math.max() method? |
@OmarMorales71 thank you for your interest! This is the most complete spec for https://tc39.es/ecma262/#sec-math.max Feel free to ask if you have any further questions! |
Interestingly if you reverse the order of parameters Also noted that this repros in both Master and release 1.11. The implementation of Math.max was changed between the two, in 1.11 it's implemented here: In master it's instead implemented with self-hosted JS here: The 1.11 C++ implementation is preserved in master as a fallback in case self-hosted JS is unavailable for some reason. It's interesting that both implementations reproduce this error. @OmarMorales71 Looking at the JS implementation, to fix the error we unfortunately need to slightly de-optimise the toNumber step is done by doing value = +value we need to do that to every parameter before we do anything that can return - try to figure out how to do that without any unnecessary steps - also we want to avoid accessing indexed argument values in the cases where we don't need to. We should also fix the C++ implementation - it will probably be a similar issue. |
Hello there i am new to open source contribution. Where can i find this piece of code in your repository? |
Have a look at the links in my previous comment should take you to the correct source files. |
Hey I want to Contribute on this Issue, Can I?? |
@anshul2807 it's a good first issue if you want to take it - though not sure if @Abdullah17m was already intending to take it? Don't want two people working on the same issue. |
Hello, @rhuanjl is this issue still available. |
The issue is still available, the error is that the function short cuts/does an early return of the first parameter is NaN. |
Hello, @rhuanjl can we solve this issue by adding a for loop before considering the first argument...
|
@rhuanjl Can We do this?
|
Is this issue resolved? Can I try to work on this? |
@Harsh-Shedge sure, you can give it a try. |
According to the spec, Math.max and Math.min should convert all args to numbers (See ToNumber). CC takes a shortcut by just returning NaN as soon as it finds a NaN arg. Therefore, possibly missing calls to valueOf of a later arg. Fix #6519
Uh oh!
There was an error while loading. Please reload this page.
When I passed NaN and an object with the "valueOf" attribute value as a callable function to the first and second parameters of Math.max, chakra did not execute this function. According to the ES10 standard, the ToNumber operation is performed on each parameter of Math.max, and the "valueOf" attribute value function of the second parameter will be executed.
version
chakra-1_11_22
command
testcase
Output
Expected behavior
Contributor : @Haobin-Lee
The text was updated successfully, but these errors were encountered: