Skip to content

Conversation

@PhoenixWhitefire
Copy link
Contributor

@PhoenixWhitefire PhoenixWhitefire commented Oct 31, 2025

Implements the read and write property attributes for external type definitions, which the embedded vector type now makes use of:

Before:

declare extern type vector with
    x: number
    y: number
    z: number
end

After:

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:

--!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))

Additionally,

  • Adds two new tests for the implemented syntax
  • Adds the LuauExternReadWriteAttributes and LuauTypeCheckerVectorReadOnly flags
  • Removes the LuauTypeCheckerVectorLerp2 flag (keeping it would lead to 4 slightly different copies of the vector library definition)
  • The LuauVectorLerp now only works for the fastcall gate, the VM will alway register the function (doing this felt better than fixing the failing tests - vector.lerp can't be disabled at this point anyway)

Closes #2062

… and make `vector` properties read-only

Adds support for `read` and `write` property attributes for extern type declarations
The structure is intended to be the same as for table types:

declare extern type E as
	(read/write/<blank>) <property>: T
end

Modifies the embedded type definition of `vector`s to mark `.x`, `.y` and `.z` as read-only
My mistake!
This is after migrating to the latest version of Luau, the previous changes were actually written on the *prior* release and copied over (imperfectly) but it should all be good now
@Stupid-Noob-Scripter
Copy link

I don't know what any of these means but I think they're pretty cool
this deserves 6-7 stars

Copy link
Collaborator

@andyfriesen andyfriesen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch!

This all looks fine. We just need you to flag it before we can merge it.

PhoenixWhitefire and others added 5 commits November 19, 2025 05:23
In order to maintain the `LuauTypeCheckerVectorLerp2` flag, I would have to add 2 extra copies of the `vector` library definitions.
`vector.lerp` has been out for several months now anyway, the rest of the rollout flags should also probably be removed...
Now, it only affects the fastcall guard
@PhoenixWhitefire
Copy link
Contributor Author

PhoenixWhitefire commented Nov 19, 2025

The flags LuauExternReadWriteAttributes and LuauTypeCheckerVectorReadOnly have been added
LuauTypeCheckerVectorLerp2 has been removed to prevent there being too many different combinations of the embedded vector definition
LuauVectorLerp no longer has any effect on the VM outside of allowing fastcalls. It felt better to do this than patch the failing test complaining about it not existing despite being defined in the type system due to the above flag removal (maybe the rest of the lerp rollout flags could also be removed, but that felt even further outside the scope of this PR and I didn't want to bring too many different areas into this)

@andyfriesen andyfriesen self-assigned this Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[new solver] compound assignment of vector components *does not* raise TypeError

3 participants