reject non-toplevel import/export (#2128)

fixes #2124
This commit is contained in:
Alex Lam S.L
2017-06-21 03:18:48 +08:00
committed by GitHub
parent 62d1fbf645
commit 11923e3ae8
5 changed files with 45 additions and 28 deletions

View File

@@ -223,6 +223,15 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
}));
node.thedef = sym;
}
if (!(scope instanceof AST_Toplevel) && (node instanceof AST_Export || node instanceof AST_Import)) {
js_error(
node.TYPE + " statement may only appear at top level",
node.start.file,
node.start.line,
node.start.col,
node.start.pos
);
}
function mark_export(def, level) {
var node = tw.parent(level);