Skip to content

Commit 1da50c6

Browse files
fix: Fix crash when inheriting from class defined in untyped code. (#42)
Encountered when indexing Homebrew/brew.
1 parent 8998907 commit 1da50c6

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

scip_indexer/SCIPIndexer.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -912,9 +912,17 @@ class CFGTraversal final {
912912
isMethodFileStaticInit ||
913913
method == gs.lookupStaticInitForClass(namedSym.asSymbolRef().asClassOrModuleRef().data(gs)->owner,
914914
/*allowMissing*/ true);
915-
ENFORCE(check);
916-
auto status = this->scipState.saveDefinition(gs, file, namedSym, arg.loc);
917-
ENFORCE(status.ok());
915+
absl::Status status;
916+
string kind;
917+
if (check) {
918+
status = this->scipState.saveDefinition(gs, file, namedSym, arg.loc);
919+
kind = "definition";
920+
} else {
921+
status = this->scipState.saveReference(gs, file, namedSym, arg.loc, 0);
922+
kind = "reference";
923+
}
924+
ENFORCE(status.ok(), "failed to save {} for {}\ncontext:\ninstruction: {}\nlocation: {}\n", kind,
925+
namedSym.showRaw(gs), binding.value.showRaw(gs, cfg), core::Loc(file, arg.loc).showRaw(gs));
918926
return true;
919927
};
920928

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

0 commit comments

Comments
 (0)