mirror of
https://github.com/luau-lang/rfcs.git
synced 2025-05-04 10:43:48 +01:00
Added a note about how this type operator doesn't work with class types
This commit is contained in:
parent
235b241b64
commit
a22eb205dd
1 changed files with 2 additions and 0 deletions
|
@ -36,6 +36,8 @@ local key = "property"
|
||||||
type age = rawget<Person, key> -- Error message: Second argument to rawget<Person, _> is not a valid index type; Unknown type 'key'
|
type age = rawget<Person, key> -- Error message: Second argument to rawget<Person, _> is not a valid index type; Unknown type 'key'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note: `rawget` type operator does not work on class types because they do not have direct fields that can be looked up without invoking its metamethod.
|
||||||
|
|
||||||
The implementation effort for this type operator is very minimal. Since the `rawget` type operator functions similarly to the `index` type operator, we can reuse the functions already used to implement the `index` type operator.
|
The implementation effort for this type operator is very minimal. Since the `rawget` type operator functions similarly to the `index` type operator, we can reuse the functions already used to implement the `index` type operator.
|
||||||
|
|
||||||
## Drawbacks
|
## Drawbacks
|
||||||
|
|
Loading…
Add table
Reference in a new issue