mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Added note on string types
This commit is contained in:
parent
485d31e7f1
commit
65115e8d0e
1 changed files with 14 additions and 0 deletions
|
@ -52,6 +52,20 @@ will, with bounded generics and this RFC, have type:
|
||||||
getP : <a, t <: {p:a}> (t) -> a
|
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
|
### Related work
|
||||||
|
|
||||||
This design is essentially the same as
|
This design is essentially the same as
|
||||||
|
|
Loading…
Add table
Reference in a new issue