aboutsummaryrefslogtreecommitdiff
path: root/lib/ast.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-21 05:01:56 +0000
committerGitHub <noreply@github.com>2021-02-21 13:01:56 +0800
commitb726e364c1164b0c828d7be04bfcfa21774366a1 (patch)
treef7bb6725d1211fe326efffa3ea52a37f19ce1fd1 /lib/ast.js
parentbfe3a8b5161457062224959bbb9938c106503f97 (diff)
downloadtracifyjs-b726e364c1164b0c828d7be04bfcfa21774366a1.tar.gz
tracifyjs-b726e364c1164b0c828d7be04bfcfa21774366a1.zip
fix corner cases with `export default` (#4673)
Diffstat (limited to 'lib/ast.js')
-rw-r--r--lib/ast.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/ast.js b/lib/ast.js
index b386b442..18169dfd 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -1060,7 +1060,7 @@ var AST_ExportDeclaration = DEFNODE("ExportDeclaration", "body", {
var AST_ExportDefault = DEFNODE("ExportDefault", "body", {
$documentation: "An `export default` statement",
$propdoc: {
- body: "[AST_Node] an expression node (should not be instanceof AST_Statement)",
+ body: "[AST_Node] the default export",
},
walk: function(visitor) {
var node = this;
@@ -1069,7 +1069,11 @@ var AST_ExportDefault = DEFNODE("ExportDefault", "body", {
});
},
_validate: function() {
- must_be_expression(this, "body");
+ if (this.body instanceof AST_Lambda && this.body.name) {
+ if (!(this.body instanceof AST_LambdaDefinition)) throw new Error("body must be AST_LambdaDefinition");
+ } else {
+ must_be_expression(this, "body");
+ }
},
}, AST_Statement);