mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Add RFC for none and unknown types
This commit is contained in:
parent
2c339d52c0
commit
3a1ecd9cc5
1 changed files with 31 additions and 0 deletions
31
rfcs/none-and-unknown-types.md
Normal file
31
rfcs/none-and-unknown-types.md
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# Add none and unknown types
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
Add top and bottom types that ane inhabited by everything and nothing respectively.
|
||||||
|
|
||||||
|
## Motivation
|
||||||
|
|
||||||
|
There are lots of cases in local type inference, semantic subtyping,
|
||||||
|
and type normalization, where it would be useful to have top and
|
||||||
|
bottom types. Currently, `any` is filling that role, but it has
|
||||||
|
special "switch off the type system" superpowers.
|
||||||
|
|
||||||
|
## Design
|
||||||
|
|
||||||
|
Add:
|
||||||
|
|
||||||
|
* a type `none`, inhabited by nothing, and
|
||||||
|
* a type `unknown`, inhabited everything.
|
||||||
|
|
||||||
|
Use them, rather than `any` where appropriate. Ideally, we would then never infer `any`.
|
||||||
|
|
||||||
|
## Drawbacks
|
||||||
|
|
||||||
|
Another bit of complexity budget spent.
|
||||||
|
|
||||||
|
These types will be visible to creators, so yay bikeshedding!
|
||||||
|
|
||||||
|
## Alternatives
|
||||||
|
|
||||||
|
Stick with the current use of `any` for these cases.
|
Loading…
Add table
Reference in a new issue