TL;DR:
new import('');
Is not allowed, per: https://tc39.github.io/proposal-dynamic-import/#sec-left-hand-side-expressions
Note currently this throws a runtime error instead of a syntax error.
Super easy fix could either:
a) check if the last token was new and if so throw here:
https://github.com/Microsoft/ChakraCore/blob/276661f908707e4d2cc6137fe94e6b5422b2b492/lib/Parser/Parse.cpp#L3578-L3583
OR
b) Check if the next token is import here and if so throw:
https://github.com/Microsoft/ChakraCore/blob/276661f908707e4d2cc6137fe94e6b5422b2b492/lib/Parser/Parse.cpp#L3461
Will submit a PR if wanted when one of my existing ones has been merged. edit: may have got impatient, PR open.
Most helpful comment
Note currently this throws a runtime error instead of a syntax error.
Super easy fix could either:
a) check if the last token was
newand if so throw here:https://github.com/Microsoft/ChakraCore/blob/276661f908707e4d2cc6137fe94e6b5422b2b492/lib/Parser/Parse.cpp#L3578-L3583
OR
b) Check if the next token is
importhere and if so throw:https://github.com/Microsoft/ChakraCore/blob/276661f908707e4d2cc6137fe94e6b5422b2b492/lib/Parser/Parse.cpp#L3461
Will submit a PR if wanted when one of my existing ones has been merged. edit: may have got impatient, PR open.