Given a table type and a table defined with it:
type callback = {
execute: () -> ()?
}
local myCallback: callback = {}
Defining a function using sugar syntax creates a warning:
-- "W000: Cannot add property 'execute' to sealed table callback"
function myCallback.execute()
-- ...
end
Whereas anonymous function assignments do not suffer from this problem:
myCallback.execute = function()
-- ...
end
Since any other type of value can be changed on demand except via sugar syntax function definitions specifically, this seems unintended.
Repro
- Create any kind of script.
- Paste this source code into it:
type callback = {
execute: () -> ()?
}
local myCallback: callback = {}
function myCallback.execute()
-- ...
end
- A warning should appear at (7, 1) saying
W000: Cannot add property 'execute' to sealed table callback
.
I found this bug today, if that helps.
Specs
- Windows 10 Home v1903
- CPU: AMD A8-5550M APU with Radeon™ HD Graphics
- 2.10 GHz
- Memory: 16.0 GB DDR3
- Roblox Studio Version 0.441.1.408989 (64bit)