Skip to content
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
18 changes: 8 additions & 10 deletions crates/oxc_semantic/src/binder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,14 @@ impl<'a> Binder<'a> for VariableDeclarator<'a> {

impl<'a> Binder<'a> for Class<'a> {
fn bind(&self, builder: &mut SemanticBuilder) {
if !self.declare {
let Some(ident) = &self.id else { return };
let symbol_id = builder.declare_symbol(
ident.span,
&ident.name,
SymbolFlags::Class,
SymbolFlags::ClassExcludes,
);
ident.symbol_id.set(Some(symbol_id));
}
let Some(ident) = &self.id else { return };
let symbol_id = builder.declare_symbol(
ident.span,
&ident.name,
SymbolFlags::Class,
SymbolFlags::ClassExcludes,
);
ident.symbol_id.set(Some(symbol_id));
}
}

Expand Down
65 changes: 62 additions & 3 deletions tasks/coverage/snapshots/parser_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ commit: 15392346
parser_typescript Summary:
AST Parsed : 6522/6531 (99.86%)
Positive Passed: 6511/6531 (99.69%)
Negative Passed: 1290/5754 (22.42%)
Negative Passed: 1292/5754 (22.45%)
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/ClassDeclaration24.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/ExportAssignment7.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/ExportAssignment8.ts
Expand Down Expand Up @@ -806,7 +806,6 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/exportDefaul
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/exportDefaultTypeClassAndValue.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/exportEqualErrorType.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/exportEqualMemberMissing.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/exportInterfaceClassAndValue.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/exportInterfaceClassAndValueWithDuplicatesInImportList.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/exportSpecifierAndLocalMemberDeclaration.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/compiler/exportSpecifierForAGlobal.ts
Expand Down Expand Up @@ -2349,7 +2348,6 @@ Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/classes/c
Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/classes/classDeclarations/classWithPredefinedTypesAsNames.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts
Expect Syntax Error: tasks/coverage/typescript/tests/cases/conformance/classes/classStaticBlock/classStaticBlock19.ts
Expand Down Expand Up @@ -8047,6 +8045,17 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private
2 │ export = 0;
╰────

× Identifier `foo` has already been declared
╭─[typescript/tests/cases/compiler/exportInterfaceClassAndValue.ts:1:14]
1 │ export const foo = 1
· ─┬─
· ╰── `foo` has already been declared here
2 │ export declare class foo {}
· ─┬─
· ╰── It can not be redeclared here
3 │ export interface foo {}
╰────

× Identifier `a` has already been declared
╭─[typescript/tests/cases/compiler/exportSameNameFuncVar.ts:1:12]
1 │ export var a = 10;
Expand Down Expand Up @@ -14309,6 +14318,30 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private
18 │
╰────

× Identifier `DCC1` has already been declared
╭─[typescript/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts:25:24]
24 │
25 │ declare abstract class DCC1 {}
· ──┬─
· ╰── `DCC1` has already been declared here
26 │ declare class DCC1 {}
· ──┬─
· ╰── It can not be redeclared here
27 │
╰────

× Identifier `DCC2` has already been declared
╭─[typescript/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts:28:15]
27 │
28 │ declare class DCC2 {}
· ──┬─
· ╰── `DCC2` has already been declared here
29 │ declare abstract class DCC2 {}
· ──┬─
· ╰── It can not be redeclared here
30 │
╰────

× TS(1244): Abstract methods can only appear within an abstract class.
╭─[typescript/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts:2:14]
1 │ class A {
Expand Down Expand Up @@ -14463,6 +14496,32 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/salsa/private
· ╰── `{` expected
╰────

× Identifier `C1` has already been declared
╭─[typescript/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts:1:15]
1 │ declare class C1 {}
· ─┬
· ╰── `C1` has already been declared here
2 │
3 │ declare class C1 {}
· ─┬
· ╰── It can not be redeclared here
4 │
╰────

× Identifier `C2` has already been declared
╭─[typescript/tests/cases/conformance/classes/classDeclarations/declaredClassMergedwithSelf.ts:5:15]
4 │
5 │ declare class C2 {}
· ─┬
· ╰── `C2` has already been declared here
6 │
7 │ interface C2 {}
8 │
9 │ declare class C2 {}
· ─┬
· ╰── It can not be redeclared here
╰────

× Private field 'y' must be declared in an enclosing class
╭─[typescript/tests/cases/conformance/classes/classStaticBlock/classStaticBlock16.ts:11:28]
10 │ getX = (obj: C) => obj.#x;
Expand Down
30 changes: 24 additions & 6 deletions tasks/coverage/snapshots/semantic_babel.snap
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,10 @@ after transform: ["A", "Error"]
rebuilt : []

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/class/abstract/input.ts
semantic error: Scope children mismatch:
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["C1", "C2", "C3", "C4", "C5"]
rebuilt : ScopeId(0): ["C1", "C3", "C4", "C5"]
Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3), ScopeId(4), ScopeId(5), ScopeId(6)]
rebuilt : ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3), ScopeId(4), ScopeId(5)]
Scope children mismatch:
Expand Down Expand Up @@ -433,12 +436,18 @@ after transform: ["T", "X", "f"]
rebuilt : ["f"]

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/class/get-generic/input.ts
semantic error: Scope children mismatch:
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["C"]
rebuilt : ScopeId(0): []
Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1)]
rebuilt : ScopeId(0): []

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/class/get-generic-babel-7/input.ts
semantic error: Scope children mismatch:
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["C"]
rebuilt : ScopeId(0): []
Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1)]
rebuilt : ScopeId(0): []

Expand Down Expand Up @@ -820,15 +829,15 @@ rebuilt : ScopeId(0): []

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/export/declare/input.ts
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["M", "N", "_bar", "bar", "f", "foo", "x"]
after transform: ScopeId(0): ["C", "M", "N", "_bar", "bar", "f", "foo", "x"]
rebuilt : ScopeId(0): []
Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3), ScopeId(4), ScopeId(5), ScopeId(6), ScopeId(7)]
rebuilt : ScopeId(0): []

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/export/declare-babel-7/input.ts
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["M", "N", "_bar", "bar", "f", "foo", "x"]
after transform: ScopeId(0): ["C", "M", "N", "_bar", "bar", "f", "foo", "x"]
rebuilt : ScopeId(0): []
Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1), ScopeId(2), ScopeId(3), ScopeId(4), ScopeId(5), ScopeId(6), ScopeId(7)]
Expand Down Expand Up @@ -1425,6 +1434,15 @@ tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/scope/callab
semantic error: Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1), ScopeId(2)]
rebuilt : ScopeId(0): [ScopeId(1)]
Symbol flags mismatch for "C":
after transform: SymbolId(0): SymbolFlags(Class | Function)
rebuilt : SymbolId(0): SymbolFlags(Function)
Symbol span mismatch for "C":
after transform: SymbolId(0): Span { start: 14, end: 15 }
rebuilt : SymbolId(0): Span { start: 29, end: 30 }
Symbol redeclarations mismatch for "C":
after transform: SymbolId(0): [Span { start: 14, end: 15 }, Span { start: 29, end: 30 }]
rebuilt : SymbolId(0): []

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/scope/callable-class-ambient/input.ts
semantic error: Bindings mismatch:
Expand Down Expand Up @@ -1590,7 +1608,7 @@ rebuilt : SymbolId(0): []

tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/scope/module-declaration-var/input.js
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["bar"]
after transform: ScopeId(0): ["bar", "foo"]
rebuilt : ScopeId(0): []
Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1), ScopeId(2)]
Expand Down
Loading