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

Handling Optional Chaining operator #293

Open
zmeggyesi opened this issue Oct 11, 2022 · 1 comment
Open

Handling Optional Chaining operator #293

zmeggyesi opened this issue Oct 11, 2022 · 1 comment

Comments

@zmeggyesi
Copy link

We've recently encountered an issue where the Shift parser doesn't seem to handle ECMA262's Conditional Chaining operator (AKA null-aware accessor, null-aware invocation, Jackson Operator, and other names). Both version 2.0.4 of the JS parser and the online demo parser fail with the same exception on the following snippet:

const adventurer = {
  name: 'Alice',
  cat: {
    name: 'Dinah'
  }
};

const dogName = adventurer.dog?.name;
console.log(dogName);

Source: MDN

Example exception from the Java library:

Exception in thread "main" com.shapesecurity.shift.es2018.parser.JsError: JavaScript error: Line 8 Column 31 (Index = 104), Unexpected token ".".
	at com.shapesecurity.shift.es2018.parser.Tokenizer.createError(Tokenizer.java:455)
	at com.shapesecurity.shift.es2018.parser.Tokenizer.createUnexpected(Tokenizer.java:439)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parsePrimaryExpression(GenericParser.java:1989)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseLeftHandSideExpression(GenericParser.java:1666)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseUpdateExpression(GenericParser.java:1521)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseUnaryExpression(GenericParser.java:1493)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseExponentiationExpression(GenericParser.java:1464)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseBinaryExpression(GenericParser.java:1403)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseConditionalExpression(GenericParser.java:1376)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseAssignmentExpressionOrTarget(GenericParser.java:1233)
	at com.shapesecurity.shift.es2018.parser.GenericParser.isolateCoverGrammar(GenericParser.java:1178)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseAssignmentExpression(GenericParser.java:1220)
	at com.shapesecurity.shift.es2018.parser.GenericParser.isolateCoverGrammar(GenericParser.java:1178)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseConditionalExpression(GenericParser.java:1386)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseAssignmentExpressionOrTarget(GenericParser.java:1233)
	at com.shapesecurity.shift.es2018.parser.GenericParser.isolateCoverGrammar(GenericParser.java:1178)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseAssignmentExpression(GenericParser.java:1220)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseVariableDeclarator(GenericParser.java:314)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseVariableDeclaratorList(GenericParser.java:294)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseVariableDeclaration(GenericParser.java:285)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseVariableDeclarationStatement(GenericParser.java:274)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseStatementListItem(GenericParser.java:265)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseBody(GenericParser.java:191)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseTopLevel(GenericParser.java:157)
	at com.shapesecurity.shift.es2018.parser.GenericParser.parseScript(GenericParser.java:166)
	at com.shapesecurity.shift.es2018.parser.Parser.parseScript(Parser.java:17)
	at hu.skawa.App.main(App.java:12)

This got me thinking, though, that other new language features may not be supported either. Is a new version forthcoming that will support these - but at least this one, since this is the one causing my organization a headache as of now - features?

@bakkot
Copy link
Member

bakkot commented Oct 11, 2022

Yeah, support for the latest features is not yet implemented, sorry. We do intend to support these but it may be a few months before we're able to get to it.

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

No branches or pull requests

2 participants