Type system forbids sugar syntax function definitions on pre-defined table types

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

  1. Create any kind of script.
  2. Paste this source code into it:
type callback = {
	execute: () -> ()?
}

local myCallback: callback = {}

function myCallback.execute()
	-- ...
end
  1. 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)
4 Likes

Thanks for the report! We’ve filed this internally and we’ll follow up here when we have an update for you.

4 Likes

I am in the process of checking over bug reports and following up on some bugs that haven’t received any activity in a while.
Is this issue still occurring or can you confirm that this bug has been resolved?

2 Likes

Yes, this bug still occurs. The reproduction steps above still create the same result.

Alright, thank. When there is more info from the engineers i will pass it on.

1 Like

Update: This bug no longer occurs! :tada:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.