Added note on string types

This commit is contained in:
ajeffrey@roblox.com 2022-07-11 15:08:39 -05:00
parent 485d31e7f1
commit 65115e8d0e

View file

@ -52,6 +52,20 @@ will, with bounded generics and this RFC, have type:
getP : <a, t <: {p:a}> (t) -> a
```
### String types
In Luau, the string type has a metatable, so is a supertype of
any appropriate shape type, for example `{ lower: (string) -> string }`.
This is necessary to support string parameters to appropriate bounded generics, for example
```lua
function getLower(x) return x:lower() end
```
which has type
```
getLower : <a, t <: {lower: (t) -> a}> (t) -> a
```
### Related work
This design is essentially the same as