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

Parse Error: BigInt with hexadecimal #525

Closed
odanado opened this issue Nov 29, 2019 · 10 comments
Closed

Parse Error: BigInt with hexadecimal #525

odanado opened this issue Nov 29, 2019 · 10 comments
Labels

Comments

@odanado
Copy link

odanado commented Nov 29, 2019

Bug report

Version
terser 4.4.0

Complete CLI command
$ terser example.js

terser input
ref: https://github.com/odanado/terser-bigint-hexadecimal

const a = 0xffn
console.log(a)

terser output or error

Parse error at example.js:1,10
const a = 0xffn
          ^
ERROR: Invalid or unexpected token
    at js_error (/Users/odan/source/github.com/odanado/terser-bigint-hexadecimal/node_modules/terser/lib/parse.js:361:11)
    at parse_error (/Users/odan/source/github.com/odanado/terser-bigint-hexadecimal/node_modules/terser/lib/parse.js:494:9)
    at read_num (/Users/odan/source/github.com/odanado/terser-bigint-hexadecimal/node_modules/terser/lib/parse.js:534:13)
    at Object.input (/Users/odan/source/github.com/odanado/terser-bigint-hexadecimal/node_modules/terser/lib/parse.js:885:40)
    at peek (/Users/odan/source/github.com/odanado/terser-bigint-hexadecimal/node_modules/terser/lib/parse.js:1023:56)
    at next (/Users/odan/source/github.com/odanado/terser-bigint-hexadecimal/node_modules/terser/lib/parse.js:1028:24)
    at vardefs (/Users/odan/source/github.com/odanado/terser-bigint-hexadecimal/node_modules/terser/lib/parse.js:2031:28)
    at const_ (/Users/odan/source/github.com/odanado/terser-bigint-hexadecimal/node_modules/terser/lib/parse.js:2065:27)
    at parser (/Users/odan/source/github.com/odanado/terser-bigint-hexadecimal/node_modules/terser/lib/parse.js:1287:28)
    at /Users/odan/source/github.com/odanado/terser-bigint-hexadecimal/node_modules/terser/lib/parse.js:1101:26

Expected result
succeed parse.

@fabiosantoscode
Copy link
Collaborator

Thanks! I didn't know one could use hex in BigDecimals

@fabiosantoscode
Copy link
Collaborator

Octal and binary are allowed too, I'll add them in.

@L2jLiga
Copy link
Contributor

L2jLiga commented Dec 1, 2019

@fabiosantoscode, this commit broke 1 test with scientific format: 1e6n - is not correct big interger
image

@paulmillr
Copy link
Contributor

@fabiosantoscode this regressed in 4.6.12

@paulmillr
Copy link
Contributor

Test case: 'let r = {beta: 0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501een}; console.log(r.beta);'

@fabiosantoscode
Copy link
Collaborator

@paulmillr thank you very much for this report. Next time though do open a new issue!

It seems to be caused by the lowercase. The workaround is to use uppercase hex.

@paulmillr
Copy link
Contributor

@fabiosantoscode thanks. Is there a possibility this will be fixed by terser?

@fabiosantoscode
Copy link
Collaborator

This is simple enough to be fixed by today or tomorrow. I have to tend to my job though :)

fabiosantoscode added a commit that referenced this issue Apr 29, 2020
@fabiosantoscode
Copy link
Collaborator

@paulmillr fix is in master. Terser gets released when most of the world is in working hours.

@paulmillr
Copy link
Contributor

awesome!

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

No branches or pull requests

4 participants