From c72464eb5581b70a6851218c85d1aa6a3a365fc5 Mon Sep 17 00:00:00 2001 From: jupblb Date: Fri, 21 Nov 2025 18:34:58 +0100 Subject: [PATCH 1/2] 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 --- scip_indexer/SCIPIndexer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scip_indexer/SCIPIndexer.cc b/scip_indexer/SCIPIndexer.cc index 3f3e4bbf2..a3a97254a 100644 --- a/scip_indexer/SCIPIndexer.cc +++ b/scip_indexer/SCIPIndexer.cc @@ -477,7 +477,7 @@ class SCIPState { ast::ExpressionPtr &constantLitExpr) { auto *expr = &constantLitExpr; while (auto *constantLit = ast::cast_tree(*expr)) { - if (constantLit->symbol.exists() && constantLit->symbol.asClassOrModuleRef().exists()) { + if (constantLit->symbol.exists() && constantLit->symbol.isClassOrModule() && constantLit->symbol.asClassOrModuleRef().exists()) { core::Context ctx(gs, constantLit->symbol, file); auto status = this->saveReference(ctx, GenericSymbolRef::classOrModule(constantLit->symbol), /*overrideType*/ std::nullopt, constantLit->loc, 0); From 1d509579c8df97eb21048668280297b062f7e613 Mon Sep 17 00:00:00 2001 From: jupblb Date: Fri, 21 Nov 2025 18:49:47 +0100 Subject: [PATCH 2/2] Add regression test for inheritance crash Amp-Thread-ID: https://ampcode.com/threads/T-3ff237da-1bb4-43d1-abb5-989b228d9f59 --- test/scip/testdata/inheritance.rb | 4 ++++ test/scip/testdata/inheritance.snapshot.rb | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/test/scip/testdata/inheritance.rb b/test/scip/testdata/inheritance.rb index ccbd2c8ec..4b16003f8 100644 --- a/test/scip/testdata/inheritance.rb +++ b/test/scip/testdata/inheritance.rb @@ -47,3 +47,7 @@ def write_f_plus_1(a) end end +Z5 = Object +class Z6 < Z5 +end + diff --git a/test/scip/testdata/inheritance.snapshot.rb b/test/scip/testdata/inheritance.snapshot.rb index dc51d5d52..ef7ee4b72 100644 --- a/test/scip/testdata/inheritance.snapshot.rb +++ b/test/scip/testdata/inheritance.snapshot.rb @@ -89,3 +89,12 @@ def write_f_plus_1(a) end end + Z5 = Object +#^^ definition [..] Z5. +#relation reference=[..] Object# +#^^^^^^^^^^^ reference [..] Z5. +# ^^^^^^ reference [..] Object# + class Z6 < Z5 +# ^^ definition [..] Z6# + end +