Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove error-prone source_id from TypeEngine::insert() and make inserting API more robust and less verbose #5991

Closed
2 tasks
ironcev opened this issue May 12, 2024 · 0 comments · Fixed by #6613
Closed
2 tasks
Assignees
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

Comments

@ironcev
Copy link
Member

ironcev commented May 12, 2024

In the TypeEngine::insert() method, the source_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 valid source_id (or None) although the choice is in most of the cases determined by the type being inserted. E.g. if we are inserting an enum the source_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 the source_id no matter where in code we insert a TypeInfo::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 to source_id and less verbose at the same time by:

  • removing source_id it from the insert() method and infer it based on the inserted type.
  • provide convenience methods for inserting common types like Unknown or built-in types.
@ironcev ironcev self-assigned this May 12, 2024
@ironcev ironcev added compiler General compiler. Should eventually become more specific as the issue is triaged compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen labels May 12, 2024
@tritao tritao closed this as completed in 73e1a7a Nov 6, 2024
@IGI-111 IGI-111 added the team:compiler Compiler Team label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants