Skip to content

Commit 811e4dd

Browse files
fix: Fix crash on having direct root references. (#43)
Ran into this while trying to reduce a crash on indexing Homebrew/brew.
1 parent 1da50c6 commit 811e4dd

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

scip_indexer/SCIPIndexer.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,8 @@ class AliasMap final {
702702
// in definition contexts) of if this is deliberate.
703703
if (sym.isClassOrModule()) {
704704
auto loc = bind.loc;
705-
if (!loc.exists() || loc.empty()) { // For special classes like Sorbet::Private::Static
705+
if (!loc.exists() || loc.empty() || sym == core::Symbols::root()) {
706+
// For special classes like Sorbet::Private::Static
706707
continue;
707708
}
708709
this->map.insert({bind.bind.variable, {NamedSymbolRef::classOrModule(sym), trim(loc), false}});
@@ -1097,7 +1098,7 @@ class CFGTraversal final {
10971098
// when other forms like 'class M::C' are present.
10981099
for (auto &[namedSym, loc] : todo) {
10991100
auto status = this->scipState.saveReference(gs, file, namedSym, loc, 0);
1100-
ENFORCE(status.ok());
1101+
ENFORCE(status.ok(), "status: {}\n", status.message());
11011102
}
11021103
}
11031104
};

test/scip/testdata/non_existent.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# typed: true
2+
3+
class D
4+
end
5+
6+
class C < ::D
7+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# typed: true
2+
3+
class D
4+
# ^ definition [..] D#
5+
end
6+
7+
class C < ::D
8+
# ^ definition [..] C#
9+
# ^ definition [..] D#
10+
end

0 commit comments

Comments
 (0)