Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 493016

Summary: [ecma6] poor error reporting when import statements have syntax errors
Product: [ECD] Orion Reporter: Olivier Thomann <Olivier_Thomann>
Component: JS ToolsAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public, Michael_Rennie
Version: 11.0   
Target Milestone: 12.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Olivier Thomann CLA 2016-05-04 13:07:41 EDT
Several errors with import statements.

1) import * from "./exports"
 should fail with a syntax error on "from" since it expects as followed by a name.
 Right now it fails inside infer because the import specifier local is undefined.
 It should properly recover from it.

2) import * as test from "./exports"
 should fail with a syntax error when the sourceType is set to "script". The problem is that the syntax error is not shown.
Comment 1 Olivier Thomann CLA 2016-05-04 13:09:10 EDT
For reference, here is the syntax for import statements:
https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Instructions/import
Comment 2 Olivier Thomann CLA 2016-05-05 19:25:35 EDT
I opened https://github.com/ternjs/acorn/issues/409 against acorn. I expected the acorn_loose to handle this and provide a recovered identifier for the missing local inside the import specifier.
In the meantime, I will provide a fix locally for orion.