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

BLOCKED - BigInt literals fail - Error: Line 37: Unexpected token ILLEGAL #2035

Open
manoharreddyporeddy opened this issue Sep 21, 2020 · 0 comments

Comments

@manoharreddyporeddy
Copy link

manoharreddyporeddy commented Sep 21, 2020

BigInt literals like 1n, 10n fail.
However, BigInt(1), BigInt(10) pass.

Steps to reproduce

Below are both Fail code that throws the error, and converted code Pass code that passes.

// Fail code
function factorial(n) {
	return n !== 1n ? n * factorial(n - 1n) : 1n;
}
// Pass code
function factorial(n) {
	return n !== BigInt(1) ? n * factorial(n - BigInt(1)) : n;
}

Expected output

Fail code should pass.
Changing all "1n" to "BigInt(1)" is frustrating, mainly not feasible to do in a project.

Actual output

BigInt literals like 1n, 10n fail throws below error:

Error: Line 37: Unexpected token ILLEGAL

Full stack:

\node_modules\esprima\dist\esprima.js:5035
			throw this.createError(index, line, col, description);
			^
Error: Line 37: Unexpected token ILLEGAL
	at ErrorHandler.constructError (\node_modules\esprima\dist\esprima.js:5012:22)
	at ErrorHandler.createError (\node_modules\esprima\dist\esprima.js:5028:27)
	at ErrorHandler.throwError (\node_modules\esprima\dist\esprima.js:5035:21)
	at Scanner.throwUnexpectedToken (\node_modules\esprima\dist\esprima.js:5164:35)
	at Scanner.scanNumericLiteral (\node_modules\esprima\dist\esprima.js:5837:19)
	at Scanner.lex (\node_modules\esprima\dist\esprima.js:6251:26)
	at Parser.nextToken (\node_modules\esprima\dist\esprima.js:2079:34)
	at Parser.parseBinaryExpression (\node_modules\esprima\dist\esprima.js:3093:19)
	at Parser.inheritCoverGrammar (\node_modules\esprima\dist\esprima.js:2285:37)
	at Parser.parseConditionalExpression (\node_modules\esprima\dist\esprima.js:3141:26) {
  index: 1224,
  lineNumber: 37,
  description: 'Unexpected token ILLEGAL'
}

Relevant references

@manoharreddyporeddy manoharreddyporeddy changed the title BigInt literals - Error: Line 37: Unexpected token ILLEGAL BLOCKED - BigInt literals fail - Error: Line 37: Unexpected token ILLEGAL Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant