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(semantic): use correct span for namespace symbols #4448

Merged
merged 2 commits into from
Jul 25, 2024
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
4 changes: 2 additions & 2 deletions crates/oxc_semantic/src/binder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use oxc_ast::{
syntax_directed_operations::{BoundNames, IsSimpleParameterList},
AstKind,
};
use oxc_span::SourceType;
use oxc_span::{GetSpan, SourceType};

use crate::{scope::ScopeFlags, symbol::SymbolFlags, SemanticBuilder};

Expand Down Expand Up @@ -368,7 +368,7 @@ impl<'a> Binder for TSModuleDeclaration<'a> {
// is made inside a the scope of a module that the symbol is modified
let ambient = if self.declare { SymbolFlags::Ambient } else { SymbolFlags::None };
builder.declare_symbol(
self.span,
self.id.span(),
self.id.name().as_str(),
SymbolFlags::NameSpaceModule | ambient,
SymbolFlags::None,
Expand Down
105 changes: 54 additions & 51 deletions tasks/coverage/parser_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5378,96 +5378,97 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts"
╰────

× Identifier `m1a` has already been declared
╭─[compiler/augmentedTypesModules.ts:5:1]
╭─[compiler/augmentedTypesModules.ts:5:8]
4 │
5 │ module m1a { var y = 2; } // error
· ────────────┬───────────
· ╰── `m1a` has already been declared here
· ─┬
· ╰── `m1a` has already been declared here
6 │ var m1a = 1; // error
· ─┬─
· ╰── It can not be redeclared here
7 │
╰────

× Identifier `m1b` has already been declared
╭─[compiler/augmentedTypesModules.ts:8:1]
╭─[compiler/augmentedTypesModules.ts:8:8]
7 │
8 │ module m1b { export var y = 2; } // error
· ────────────────┬──────────────
· ╰── `m1b` has already been declared here
· ─┬
· ╰── `m1b` has already been declared here
9 │ var m1b = 1; // error
· ─┬─
· ╰── It can not be redeclared here
10 │
╰────

× Identifier `m1d` has already been declared
╭─[compiler/augmentedTypesModules.ts:16:1]
15 │
16 │ ╭─▶ module m1d { // error
17 │ │ export class I { foo() { } }
18 │ ├─▶ }
· ╰──── `m1d` has already been declared here
19 │ var m1d = 1; // error
· ─┬─
· ╰── It can not be redeclared here
20 │
╭─[compiler/augmentedTypesModules.ts:16:8]
15 │
16 │ module m1d { // error
· ─┬─
· ╰── `m1d` has already been declared here
17 │ export class I { foo() { } }
18 │ }
19 │ var m1d = 1; // error
· ─┬─
· ╰── It can not be redeclared here
20 │
╰────

× Identifier `m2a` has already been declared
╭─[compiler/augmentedTypesModules.ts:25:1]
╭─[compiler/augmentedTypesModules.ts:25:8]
24 │
25 │ module m2a { var y = 2; }
· ────────────┬───────────
· ╰── `m2a` has already been declared here
· ─┬
· ╰── `m2a` has already been declared here
26 │ function m2a() { }; // error since the module is instantiated
· ─┬─
· ╰── It can not be redeclared here
27 │
╰────

× Identifier `m2b` has already been declared
╭─[compiler/augmentedTypesModules.ts:28:1]
╭─[compiler/augmentedTypesModules.ts:28:8]
27 │
28 │ module m2b { export var y = 2; }
· ────────────────┬──────────────
· ╰── `m2b` has already been declared here
· ─┬
· ╰── `m2b` has already been declared here
29 │ function m2b() { }; // error since the module is instantiated
· ─┬─
· ╰── It can not be redeclared here
30 │
╰────

× Identifier `m2a` has already been declared
╭─[compiler/augmentedTypesModules2.ts:5:1]
╭─[compiler/augmentedTypesModules2.ts:5:8]
4 │
5 │ module m2a { var y = 2; }
· ────────────┬───────────
· ╰── `m2a` has already been declared here
· ─┬
· ╰── `m2a` has already been declared here
6 │ function m2a() { }; // error since the module is instantiated
· ─┬─
· ╰── It can not be redeclared here
7 │
╰────

× Identifier `m2b` has already been declared
╭─[compiler/augmentedTypesModules2.ts:8:1]
╭─[compiler/augmentedTypesModules2.ts:8:8]
7 │
8 │ module m2b { export var y = 2; }
· ────────────────┬──────────────
· ╰── `m2b` has already been declared here
· ─┬
· ╰── `m2b` has already been declared here
9 │ function m2b() { }; // error since the module is instantiated
· ─┬─
· ╰── It can not be redeclared here
10 │
╰────

× Identifier `m2cc` has already been declared
╭─[compiler/augmentedTypesModules2.ts:14:1]
╭─[compiler/augmentedTypesModules2.ts:14:8]
13 │
14 │ module m2cc { export var y = 2; }
· ────────────────┬───────────────
· ╰── `m2cc` has already been declared here
· ──┬
· ╰── `m2cc` has already been declared here
15 │ function m2cc() { }; // error to have module first
· ──┬─
· ╰── It can not be redeclared here
Expand Down Expand Up @@ -7319,16 +7320,17 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts"
╰────

× Identifier `F` has already been declared
╭─[compiler/duplicateSymbolsExportMatching.ts:49:5]
48 │ module M {
49 │ ╭─▶ module F {
50 │ │ var t;
51 │ ├─▶ }
· ╰──── `F` has already been declared here
52 │ export function F() { } // Only one error for duplicate identifier (don't consider visibility)
· ┬
· ╰── It can not be redeclared here
53 │ }
╭─[compiler/duplicateSymbolsExportMatching.ts:49:12]
48 │ module M {
49 │ module F {
· ┬
· ╰── `F` has already been declared here
50 │ var t;
51 │ }
52 │ export function F() { } // Only one error for duplicate identifier (don't consider visibility)
· ┬
· ╰── It can not be redeclared here
53 │ }
╰────

× Empty parenthesized expression
Expand Down Expand Up @@ -9308,16 +9310,17 @@ Expect to Parse: "conformance/salsa/typeFromPropertyAssignmentWithExport.ts"
help: Remove the duplicate modifier.

× Identifier `z` has already been declared
╭─[compiler/nameCollisions.ts:10:5]
9 │
10 │ ╭─▶ module z {
11 │ │ var t;
12 │ ├─▶ }
· ╰──── `z` has already been declared here
13 │ var z; // error
· ┬
· ╰── It can not be redeclared here
14 │
╭─[compiler/nameCollisions.ts:10:12]
9 │
10 │ module z {
· ┬
· ╰── `z` has already been declared here
11 │ var t;
12 │ }
13 │ var z; // error
· ┬
· ╰── It can not be redeclared here
14 │
╰────

× Identifier `C` has already been declared
Expand Down