Remove error-prone source_id
from TypeEngine::insert()
and make inserting API more robust and less verbose
#5991
Labels
compiler: frontend
Everything to do with type checking, control flow analysis, and everything between parsing and IRgen
compiler
General compiler. Should eventually become more specific as the issue is triaged
team:compiler
Compiler Team
In the
TypeEngine::insert()
method, thesource_id
parameter must be correctly provided in order for the LSP garbage collection to work properly.The current signature of
insert()
is quite error-prone in that regard and verbose in many cases (e.g. inserting built-in types). The caller has to choose the validsource_id
(orNone
) although the choice is in most of the cases determined by the type being inserted. E.g. if we are inserting an enum thesource_id
must always come from the enum declaration span. (This is something we will very likely change in #6603, but until then, inserting an enum should always follow the same logic for picking thesource_id
no matter where in code weinsert
aTypeInfo::Enum
.)Currently, since we are inserting same types at various places in code, it is only the convention that makes the
source_id
always defined in the same way for a particular type.Therefore, the proposal is to make the
insert()
API robust in regard tosource_id
and less verbose at the same time by:source_id
it from theinsert()
method and infer it based on the inserted type.Unknown
or built-in types.The text was updated successfully, but these errors were encountered: