You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implements the `read` and `write` property attributes for external type
definitions, which the embedded `vector` type now makes use of:
**Before:**
```luau
declare extern type vector with
x: number
y: number
z: number
end
```
**After:**
```luau
declare extern type vector with
read x: number
read y: number
read z: number
end
```
The following code now creates type-errors in the expected places:
```luau
--!strict
local function increment(v: vector)
v.x += 1 -- TE
v.x -= 1 -- TE
v.y *= 1 -- TE
v.z /= 1 -- TE
print(v.x) -- No TE
print(v.x > 5) -- No TE
v.x = 15 -- TE
end
increment(vector.create(1, 2, 3))
```
This PR also supports different read/write types:
```luau
-- Definition
declare extern type Foo with
read Bar: number
write Bar: string
end
-- Script
local f: Foo
local b: number = f.Bar
f.Bar = "Hello, World!"
```
Additionally,
* Adds two new tests for the implemented syntax
* Adds the `LuauLValueCompoundAssignmentVisitLhs`,
`LuauExternReadWriteAttributes` and `LuauTypeCheckerVectorReadOnly`
flags
Closesluau-lang#2062
0 commit comments