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

Introduce a Never type for diverging expressions #5524

Closed
jjcnn opened this issue Jan 29, 2024 · 1 comment
Closed

Introduce a Never type for diverging expressions #5524

jjcnn opened this issue Jan 29, 2024 · 1 comment
Labels
code quality compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: ir IRgen and sway-ir including optimization passes compiler General compiler. Should eventually become more specific as the issue is triaged

Comments

@jjcnn
Copy link
Contributor

jjcnn commented Jan 29, 2024

The typechecker currently uses the Unknown type both as a placeholder for a not-yet-determined type, and to indicate the type of a (typechecked) diverging expression (e.g., return, break or continue). This conflation causes some convoluted IR generation code because the code generator cannot handle Unkonwn types.

Introducing a Never type to indicate diverging expressions would fix this problem, and thus allow a simplification of the IR code generation.

@jjcnn jjcnn added compiler General compiler. Should eventually become more specific as the issue is triaged code quality compiler: ir IRgen and sway-ir including optimization passes compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen labels Jan 29, 2024
@ironcev
Copy link
Member

ironcev commented Feb 7, 2024

As explained in #5562 we need the proper bottom type in general in all compilation phases.

Closing this issue in favor of #5562 which tracks the overall effort.

@ironcev ironcev closed this as completed Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: ir IRgen and sway-ir including optimization passes compiler General compiler. Should eventually become more specific as the issue is triaged
Projects
None yet
Development

No branches or pull requests

2 participants