Skip to content

Commit

Permalink
Fix identifier handling on export { default as ... } (#1257)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO authored May 8, 2020
1 parent f6501a9 commit b5cb60f
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2473,7 +2473,7 @@ export class Parser extends DiagnosticEmitter {

// before: Identifier ('as' Identifier)?

if (tn.skipIdentifier()) {
if (tn.skipIdentifier(IdentifierHandling.ALWAYS)) {
let identifier = Node.createIdentifierExpression(tn.readIdentifier(), tn.range());
let asIdentifier: IdentifierExpression | null = null;
if (tn.skip(Token.AS)) {
Expand Down
2 changes: 2 additions & 0 deletions tests/compiler/reexport.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
(export "exportstar.renamed_c" (global $export/c))
(export "exportstar.ns.two" (func $export/ns.one))
(export "exportstar.default.two" (func $export/ns.one))
(export "default" (func $export/ns.one))
(export "renamed_default" (func $export/ns.one))
(func $export/add (param $0 i32) (param $1 i32) (result i32)
local.get $0
local.get $1
Expand Down
3 changes: 3 additions & 0 deletions tests/compiler/reexport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ export { ns as renamed_ns } from "./export";

import * as exportstar from "./exportstar";
export { exportstar };

export { default } from "./export-default";
export { default as renamed_default } from "./export-default";
5 changes: 5 additions & 0 deletions tests/compiler/reexport.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
(export "exportstar.renamed_c" (global $export/c))
(export "exportstar.ns.two" (func $export/ns.two))
(export "exportstar.default.two" (func $export/ns.two))
(export "default" (func $export-default/theDefault))
(export "renamed_default" (func $export-default/theDefault))
(start $~start)
(func $export/add (param $0 i32) (param $1 i32) (result i32)
local.get $0
Expand Down Expand Up @@ -58,6 +60,9 @@
(func $export/ns.two
nop
)
(func $export-default/theDefault
nop
)
(func $~start
call $start:reexport
)
Expand Down
6 changes: 6 additions & 0 deletions tests/compiler/rereexport.optimized.wat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(module
(type $none_=>_none (func))
(memory $0 0)
(global $export/a i32 (i32.const 1))
(global $export/b i32 (i32.const 2))
Expand All @@ -7,4 +8,9 @@
(export "renamed_a" (global $export/a))
(export "renamed_b" (global $export/b))
(export "renamed_renamed_b" (global $export/b))
(export "default" (func $export-default/theDefault))
(export "renamed_default" (func $export-default/theDefault))
(func $export-default/theDefault
nop
)
)
4 changes: 3 additions & 1 deletion tests/compiler/rereexport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ export {
a,
a as renamed_a,
renamed_b,
renamed_b as renamed_renamed_b
renamed_b as renamed_renamed_b,
default,
default as renamed_default
} from "./reexport";
5 changes: 5 additions & 0 deletions tests/compiler/rereexport.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
(export "renamed_a" (global $export/a))
(export "renamed_b" (global $export/b))
(export "renamed_renamed_b" (global $export/b))
(export "default" (func $export-default/theDefault))
(export "renamed_default" (func $export-default/theDefault))
(start $~start)
(func $export/add (param $0 i32) (param $1 i32) (result i32)
local.get $0
Expand All @@ -35,6 +37,9 @@
(func $start:rereexport
call $start:reexport
)
(func $export-default/theDefault
nop
)
(func $~start
call $start:rereexport
)
Expand Down
6 changes: 6 additions & 0 deletions tests/compiler/wildcard-export.optimized.wat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(module
(type $none_=>_none (func))
(memory $0 0)
(global $export/a i32 (i32.const 1))
(global $export/b i32 (i32.const 2))
Expand All @@ -7,4 +8,9 @@
(export "renamed_a" (global $export/a))
(export "renamed_b" (global $export/b))
(export "renamed_renamed_b" (global $export/b))
(export "default" (func $export-default/theDefault))
(export "renamed_default" (func $export-default/theDefault))
(func $export-default/theDefault
nop
)
)
5 changes: 5 additions & 0 deletions tests/compiler/wildcard-export.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
(export "renamed_a" (global $export/a))
(export "renamed_b" (global $export/b))
(export "renamed_renamed_b" (global $export/b))
(export "default" (func $export-default/theDefault))
(export "renamed_default" (func $export-default/theDefault))
(start $~start)
(func $export/add (param $0 i32) (param $1 i32) (result i32)
local.get $0
Expand Down Expand Up @@ -38,6 +40,9 @@
(func $start:wildcard-export
call $start:rereexport
)
(func $export-default/theDefault
nop
)
(func $~start
call $start:wildcard-export
)
Expand Down

0 comments on commit b5cb60f

Please sign in to comment.