Skip to content

Commit

Permalink
fix: report error for mulitple union type
Browse files Browse the repository at this point in the history
Fixes: #2870
  • Loading branch information
HerrCai0907 committed Sep 24, 2024
1 parent f79391c commit 32e5f64
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ export class Parser extends DiagnosticEmitter {
}
// ... | type
while (tn.skip(Token.Bar)) {
let nextType = this.parseType(tn, false, true);
let nextType = this.parseType(tn, true, false);
if (!nextType) return null;
let typeIsNull = type.kind == NodeKind.NamedType && (<NamedTypeNode>type).isNull;
let nextTypeIsNull = nextType.kind == NodeKind.NamedType && (<NamedTypeNode>nextType).isNull;
Expand Down
9 changes: 9 additions & 0 deletions tests/parser/union.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function foo(a: aaa | bbb | ccc): i32 {
return 1;
}

export function bar(a: i32 | u32 | f32): i32 {
return 1;
}

export let a: i32 | u32 | f32 | null = 1;
4 changes: 4 additions & 0 deletions tests/parser/union.ts.fixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export let a = 1;
// ERROR 100: "Not implemented: union types" in union.ts(1,36+3)
// ERROR 100: "Not implemented: union types" in union.ts(5,36+3)
// ERROR 100: "Not implemented: union types" in union.ts(9,27+10)

0 comments on commit 32e5f64

Please sign in to comment.