mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Update syntax-metatable-type-annotation.md
This commit is contained in:
parent
e2f72a92d5
commit
982eca25eb
1 changed files with 5 additions and 1 deletions
|
@ -169,6 +169,10 @@ setmetatable({
|
|||
})
|
||||
```
|
||||
|
||||
Another issue is the unfortunate wart in syntax with bounded quantification, for example if we want a generic to only range over types that defines a `__add` metamethod: (using invented notation) `<a: setmetatable({}, {__add: (a, a) -> a})>(a) -> a`.
|
||||
|
||||
This syntax also exposes an opportunity to write things like `setmetatable(Instance, { ... })` where `Instance` is a class type variable, forcing us to write in more code that produces a type error on nonsensical use of `setmetatable`.
|
||||
|
||||
### 2: `setmetatable<>`
|
||||
|
||||
```lua
|
||||
|
@ -181,7 +185,7 @@ It still does not grant us any syntax to return the metatable of the type, or `n
|
|||
|
||||
This option would mean `withmetatable<>` and `getmetatable<>` are the first exported types in Luau's prelude, which is not something that we want to do at this time.
|
||||
|
||||
This option has the same issue as `setmetatable()` on formatting.
|
||||
This option has the same issue as `setmetatable()` on formatting, unfortunate quirk in syntax with bounded quantification, and requires dealing with edge cases where `T` is not a table.
|
||||
|
||||
### 3: `{ @metatable {} }` (status quo when performing `Luau::toString`)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue