diff --git a/src/query.cc b/src/query.cc index 71259e96..32907fcc 100644 --- a/src/query.cc +++ b/src/query.cc @@ -694,6 +694,13 @@ void QueryDatabase::ImportOrUpdate(const std::vector& upda auto it = usr_to_symbol.find(def.usr); assert(it != usr_to_symbol.end()); + if (it->second.kind != SymbolKind::Type) { + std::cerr << "!! Import/update got symbol kind " << (int)(it->second.kind) << ", expected SymbolKind::Type for usr " << def.usr << std::endl; + continue; + } + + assert(it->second.idx >= 0 && it->second.idx < types.size()); + optional& existing = types[it->second.idx]; if (!existing) existing = QueryType(def.usr); @@ -716,6 +723,13 @@ void QueryDatabase::ImportOrUpdate(const std::vector& upda auto it = usr_to_symbol.find(def.usr); assert(it != usr_to_symbol.end()); + if (it->second.kind != SymbolKind::Func) { + std::cerr << "!! Import/update got symbol kind " << (int)(it->second.kind) << ", expected SymbolKind::Func for usr " << def.usr << std::endl; + continue; + } + + assert(it->second.idx >= 0 && it->second.idx < funcs.size()); + optional& existing = funcs[it->second.idx]; if (!existing) existing = QueryFunc(def.usr); @@ -738,6 +752,13 @@ void QueryDatabase::ImportOrUpdate(const std::vector& updat auto it = usr_to_symbol.find(def.usr); assert(it != usr_to_symbol.end()); + if (it->second.kind != SymbolKind::Var) { + std::cerr << "!! Import/update got symbol kind " << (int)(it->second.kind) << ", expected SymbolKind::Var for usr " << def.usr << std::endl; + continue; + } + + assert(it->second.idx >= 0 && it->second.idx < vars.size()); + optional& existing = vars[it->second.idx]; if (!existing) existing = QueryVar(def.usr); @@ -761,4 +782,4 @@ void QueryDatabase::UpdateDetailedNames(size_t* qualified_name_index, SymbolKind else { detailed_names[*qualified_name_index] = name; } -} \ No newline at end of file +}