diff --git a/scip_indexer/SCIPIndexer.cc b/scip_indexer/SCIPIndexer.cc index e1c4acbca7..04fd2be5e9 100644 --- a/scip_indexer/SCIPIndexer.cc +++ b/scip_indexer/SCIPIndexer.cc @@ -702,7 +702,8 @@ class AliasMap final { // in definition contexts) of if this is deliberate. if (sym.isClassOrModule()) { auto loc = bind.loc; - if (!loc.exists() || loc.empty()) { // For special classes like Sorbet::Private::Static + if (!loc.exists() || loc.empty() || sym == core::Symbols::root()) { + // For special classes like Sorbet::Private::Static continue; } this->map.insert({bind.bind.variable, {NamedSymbolRef::classOrModule(sym), trim(loc), false}}); @@ -1089,7 +1090,7 @@ class CFGTraversal final { // when other forms like 'class M::C' are present. for (auto &[namedSym, loc] : todo) { auto status = this->scipState.saveReference(gs, file, namedSym, loc, 0); - ENFORCE(status.ok()); + ENFORCE(status.ok(), "status: {}\n", status.message()); } } }; diff --git a/test/scip/testdata/non_existent.rb b/test/scip/testdata/non_existent.rb new file mode 100644 index 0000000000..e73b719208 --- /dev/null +++ b/test/scip/testdata/non_existent.rb @@ -0,0 +1,7 @@ +# typed: true + +class D +end + +class C < ::D +end diff --git a/test/scip/testdata/non_existent.snapshot.rb b/test/scip/testdata/non_existent.snapshot.rb new file mode 100644 index 0000000000..8fde9a1350 --- /dev/null +++ b/test/scip/testdata/non_existent.snapshot.rb @@ -0,0 +1,10 @@ + # typed: true + + class D +# ^ definition [..] D# + end + + class C < ::D +# ^ definition [..] C# +# ^ definition [..] D# + end