diff --git a/scip_indexer/SCIPIndexer.cc b/scip_indexer/SCIPIndexer.cc index 7b33c0602..a853bc7f7 100644 --- a/scip_indexer/SCIPIndexer.cc +++ b/scip_indexer/SCIPIndexer.cc @@ -399,6 +399,7 @@ class SCIPState { [this, &gs](UntypedGenericSymbolRef sym, std::string &out) { auto status = this->saveSymbolString(gs, sym, nullptr, out); ENFORCE(status.skip() || status.ok()); + return status.ok(); }); } diff --git a/scip_indexer/SCIPSymbolRef.cc b/scip_indexer/SCIPSymbolRef.cc index 97f68affd..ba9530a5e 100644 --- a/scip_indexer/SCIPSymbolRef.cc +++ b/scip_indexer/SCIPSymbolRef.cc @@ -132,7 +132,7 @@ string UntypedGenericSymbolRef::showRaw(const core::GlobalState &gs) const { void UntypedGenericSymbolRef::saveParentRelationships( const core::GlobalState &gs, const RelationshipsMap &relationshipMap, SmallVec &rels, - const absl::FunctionRef &saveSymbolString) const { + const absl::FunctionRef &saveSymbolString) const { auto it = relationshipMap.find(*this); if (it == relationshipMap.end()) { return; @@ -141,7 +141,9 @@ void UntypedGenericSymbolRef::saveParentRelationships( if (!this->name.exists()) { fmt::print(stderr, "problematic symbol {}\n", this->selfOrOwner.toStringFullName(gs)); } - saveSymbolString(UntypedGenericSymbolRef::field(klass, this->name), *rel.mutable_symbol()); + if (!saveSymbolString(UntypedGenericSymbolRef::field(klass, this->name), *rel.mutable_symbol())) { + return; + } ENFORCE(!rel.symbol().empty()); rels.push_back(move(rel)); }; diff --git a/scip_indexer/SCIPSymbolRef.h b/scip_indexer/SCIPSymbolRef.h index e26e61643..7ed746271 100644 --- a/scip_indexer/SCIPSymbolRef.h +++ b/scip_indexer/SCIPSymbolRef.h @@ -70,9 +70,10 @@ class UntypedGenericSymbolRef final { utils::Result symbolForExpr(const core::GlobalState &gs, const GemMapping &gemMap, std::optional loc, scip::Symbol &symbol) const; + // saveSymbolString returns false when the parent has no indexable symbol. void saveParentRelationships( const core::GlobalState &gs, const RelationshipsMap &relationshipMap, SmallVec &rels, - const absl::FunctionRef &saveSymbolString) const; + const absl::FunctionRef &saveSymbolString) const; std::string showRaw(const core::GlobalState &gs) const; }; diff --git a/test/scip/testdata/skipped_parent_relationships.rb b/test/scip/testdata/skipped_parent_relationships.rb new file mode 100644 index 000000000..dfd6264cc --- /dev/null +++ b/test/scip/testdata/skipped_parent_relationships.rb @@ -0,0 +1,7 @@ +# typed: true + +describe "example" do + before { @value = 1 } +end + +@value diff --git a/test/scip/testdata/skipped_parent_relationships.snapshot.rb b/test/scip/testdata/skipped_parent_relationships.snapshot.rb new file mode 100644 index 000000000..596438254 --- /dev/null +++ b/test/scip/testdata/skipped_parent_relationships.snapshot.rb @@ -0,0 +1,15 @@ + # typed: true + +#⌄ enclosing_range_start [..] ``# + describe "example" do +# ^^^^^^^^^ definition [..] ``# +# ⌄ enclosing_range_start [..] ``#``(). + before { @value = 1 } +# ^^^^^^ definition [..] ``#``(). +# ^^^^^^ definition [..] ``#`@value`. +# ^^^^^^^^^^ reference [..] ``#`@value`. +# ⌃ enclosing_range_end [..] ``#``(). + end +# ⌃ enclosing_range_end [..] ``# + + @value