in the SLua editor, "uuid" is not highlighted, but "key" is
tracked
SuzannaLinn Resident
Second Life Project Lua Editor 7.1.12.13858460198 (64bit)
-----------------------------------------------------------
myUuid = uuid("0f16c0e1-384e-4b5f-b7ce-886dda3bce41")
-- "uuid" is not highlighted, integer, vector and rotation/quaternion are
someTable = {}
for key, value in pairs(someTable) do -- the variable "key" is highlighted
-- something
end
Log In
H
Harold Linden
tracked
H
Harold Linden
Thanks, we'll look at getting this fixed!
Wulfie Reanimator
It's kind of a messy situation at the moment, I dunno what would be the best way forward.
- "key" and "integer" are highlighted as types.. which is correct for LSL, but notfor SLua. We don't have akeyorintegertype, they areuserdata.
- "vector" is a real type in SLua, so it's correctly highlighted (even if as accidental carry-over from LSL).
- "uuid" is not a real type, so it shouldn'tbe highlighted as a type.uuid(some_id)is a function call that returns SLuauserdata.
say = ll.OwnerSay
say("Real types:")
say(`NUMBER {type(tonumber(0))} -> {typeof(tonumber(0))}`)
say(`STRING {type(tostring(0))} -> {typeof(tostring(0))}`)
say(`VECTOR {type(vector(0,0,0))} -> {typeof(vector(0,0,0))}`)
say("Fake types:")
say(`ROTATION {type(rotation(0,0,0,1))} -> {typeof(rotation(0,0,0,1))}`)
say(`INTEGER {type(integer(0))} -> {typeof(integer(0))}`)
say(`UUID {type(uuid("test"))} -> {typeof(uuid("test"))}`)
H
Harold Linden
Wulfie Reanimator
Yep,
type()
in Luau tries to behave the same as Lua proper in that it returns the VM's underlying storage type, but it has a number of quirks in that lightuserdata
s like integer
s are also reported as userdata even though they are not, they're pointer-sized value types. It's generally preferred to use Luau's typeof()
which will return the _actual_ user-facing type of the value, rather than return how the value is handled within the VM. userdata
or lightuserdata
being the type of the TValue
is a bit of an implementation detail, and we'd consider replacing type()
with typeof()
's implementation if it wasn't liable to cause weird compatibility issues with Luau.On that note, we think it makes sense to treat
uuid
and friends as distinct types, and that would be consistent with how Roblox treats typing for their own userdata
-derived types in their Luau type packs. It has a unique metatable, can only be compared with other uuid
instances, and has a unique userdata
type tag (a Luau detail that does not exist in PUC-Rio Lua.)The whole in-viewer editor and accompanying syntax highlighting will need a total rework at some point. The current SLua editor is very much a minimum viable implementation.
Wulfie Reanimator
Thank you for the clarification, both here and in the other tickets you've responded. It's been very interesting to read them all.