[Proposal]: never/bottom type
- Dominant language
- C#
- Stars
- 12.7k
- Forks
- 1.1k
- Avg merge
- 11h 1m
- Merged PRs (30d)
- 3
Description
# `never`/`bottom` type
* Discussion: https://github.com/dotnet/csharplang/discussions/8603
## Summary
[summary]: #summary
A new type that has no instances and is a subtype of every other type can be introduced, called `never` or `bottom`. It will be the official return type of the `throw` expression and will allow transforming `return`, `break`, `continue` and `goto` into expressions (see https://github.com/dotnet/csharplang/issues/176). This will allow them in all expression contexts where `never` is combined with another type (`&&`, `||`, `??`, `?:`) or discarded (expression statements). Instantiating variables/fields of type `never` should be impossible.
It can either be implemented as a real CLR type (well, as real as `void`) or as a compiler trick (`never`-returning methods are actually `void` with a `NeverReturnsAttribute`).
## Design meetings
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.