Skip to content

Commit 5b70f41

Browse files
Fix debug assertion violation for document highlights on export = in merged namespace (#3818)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
1 parent a697eb3 commit 5b70f41

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package fourslash_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/microsoft/typescript-go/internal/fourslash"
7+
"github.com/microsoft/typescript-go/internal/testutil"
8+
)
9+
10+
func TestDocumentHighlightsExportEqualsInMergedNamespace(t *testing.T) {
11+
t.Parallel()
12+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
13+
const content = `
14+
class C {}
15+
namespace C {
16+
/*marker*/export = C;
17+
}
18+
`
19+
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
20+
defer done()
21+
f.VerifyBaselineDocumentHighlights(t, nil /*preferences*/, "marker")
22+
}

internal/ls/findallreferences.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,8 +1373,8 @@ func (l *LanguageService) getReferencedSymbolsForModule(ctx context.Context, pro
13731373
references = append(references, newNodeEntry(decl.AsModuleDeclaration().Name()))
13741374
}
13751375
default:
1376-
// This may be merged with something.
1377-
debug.Assert(symbol.Flags&ast.SymbolFlagsTransient != 0, "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration.")
1376+
// This may be merged with something (e.g. a class merged with a namespace).
1377+
continue
13781378
}
13791379
}
13801380
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// === documentHighlights ===
2+
// === /documentHighlightsExportEqualsInMergedNamespace.ts ===
3+
//
4+
// class C {}
5+
// namespace [|C|] {
6+
// /*HIGHLIGHTS*/[|export|] = C;
7+
// }
8+
//

0 commit comments

Comments
 (0)