Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix identifier handling on export { default as ... } #1257

Merged
merged 1 commit into from
May 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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