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

BigInt #93

Closed
neumatho opened this issue Sep 17, 2020 · 12 comments · Fixed by #94
Closed

BigInt #93

neumatho opened this issue Sep 17, 2020 · 12 comments · Fixed by #94

Comments

@neumatho
Copy link

neumatho commented Sep 17, 2020

Hi,

If you using a really big number in hexadecimal format, e.g. this one taken from your unit test 0x12300000000000000000000000000000000n, then the value of the Literal node only get the value of 9 instead of the real number, which is 99022168773993092867842010762644549533696.

I think it is because your doing a parseInt on a number that have exponential included.

The type of the node is also BigIntLiteral, which should only be Literal according to the specification.

-Thomas

@KFlash
Copy link
Contributor

KFlash commented Sep 17, 2020

Thanks for this info! This was done by some students of mine. Do you want to do a PR to solve it?

@neumatho
Copy link
Author

Well, I was hoping that someone on the Meriyah team will fix it :-)

@KFlash
Copy link
Contributor

KFlash commented Sep 17, 2020

cc/ @3cp Any insight in this issue?

@3cp
Copy link
Member

3cp commented Sep 18, 2020

My PR didn't change the type BigIntLiteral to Literal. I will double check estree spec.

@neumatho
Copy link
Author

Just want to be sure that the changes work. Note that the parser does different things depending if your giving a big number as a normal number or in hexadecimal. I think you may loose precision for hexadecimal. Please double check with the number given above.

-Thomas

@3cp
Copy link
Member

3cp commented Sep 18, 2020

Yes, your case is added into the unit tests.

@3cp
Copy link
Member

3cp commented Sep 18, 2020

Thomas, the BigIntLiteral is right in the spec, a sub class of Literal. https://github.com/estree/estree/blob/d1cb85c0da029f905d3ef1930cec26d836f9d73f/es2020.md#bigintliteral

@neumatho
Copy link
Author

You're right it is a new interface, but the type does not change, like for regex literals: https://github.com/estree/estree/blob/d1cb85c0da029f905d3ef1930cec26d836f9d73f/es5.md#literal. They are also called Literal as type.

If you try a bigint with Acorn on https://astexplorer.net/, then you will see it is also called Literal.

@3cp
Copy link
Member

3cp commented Sep 19, 2020

I see, you are right.
We probably need to double check all estree interfaces.

@3cp
Copy link
Member

3cp commented Sep 21, 2020

@neumatho pls try v3.0.0.

@3cp
Copy link
Member

3cp commented Sep 24, 2020

@neumatho the v3.0.0 was shipped with wrong dist files. Pls try v3.0.1.

@neumatho
Copy link
Author

That seems to work.

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.

3 participants