Skip to content

Commit c72464e

Browse files
committed
Fix assertion failure in saveQualifierReferences
Check that the symbol is a class or module before calling asClassOrModuleRef(). This prevents crashes when processing symbols that are not classes or modules (e.g. fields or methods) but are encountered in contexts where a class or module reference was assumed. Amp-Thread-ID: https://ampcode.com/threads/T-3ff237da-1bb4-43d1-abb5-989b228d9f59
1 parent aaea9cd commit c72464e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scip_indexer/SCIPIndexer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ class SCIPState {
477477
ast::ExpressionPtr &constantLitExpr) {
478478
auto *expr = &constantLitExpr;
479479
while (auto *constantLit = ast::cast_tree<ast::ConstantLit>(*expr)) {
480-
if (constantLit->symbol.exists() && constantLit->symbol.asClassOrModuleRef().exists()) {
480+
if (constantLit->symbol.exists() && constantLit->symbol.isClassOrModule() && constantLit->symbol.asClassOrModuleRef().exists()) {
481481
core::Context ctx(gs, constantLit->symbol, file);
482482
auto status = this->saveReference(ctx, GenericSymbolRef::classOrModule(constantLit->symbol),
483483
/*overrideType*/ std::nullopt, constantLit->loc, 0);

0 commit comments

Comments
 (0)