Typed Luau behaves badly with private variables & crashes studio

I have accidentally come across a bug that was giving me this error:

And in further inspection, I discovered that a mini OOP class w/private variables will crash studio:

I’m actually super confused because I could only reproduce this with an underscore variable & nothing else.

Code:

--!strict
local main = {}
main.tbl = {}
main.__index = main
setmetatable(main,main)

function main.add(name: string,func: (any) -> nil)
	main.tbl[name] = func
end

Steps to reproduce:

  1. edit the main.tbl[name] line & add _ infront of the tbl
  2. add _ infront of main.tbl above
  3. voila, click & crash
9 Likes

Thanks for the report! We’ve filed a ticket to our internal database and we’ll follow up when we have an update for you.

4 Likes

I have received some info from the engineers regarding this issue. In the meantime, the engineer has suggested a work around until a fix can be implemented. When i receive more info i will pass it on.

local main = {}
main.__index = main

function main.new()
    return setmetatable({}, main)
end

function main:method()
    print('hello!')
end

local m = main.new()
m:method()
2 Likes