@deprecated function attribute is lost when intersecting / unioning two tables

After intersecting / unioning two tables, it appears that function deprecation info is lost in the process. Other function-related info, such as the function descriptions and types, appear to still be retained.

Take the following code example:

local module = {}

-- Description
@deprecated
function module:foo(arg: string?): number?
	return 0
end

local bar = module :: typeof(module) & {}
bar:foo() -- No deprecation warning

bar = bar :: typeof(module)
bar:foo() -- Deprecation warning. "Member 'foo' is deprecated"

In this example, we have a table named module which contains the function foo which is a deprecated function. We later create a new variable named bar and set the type of this to the intersection of module and an empty table. Attempts to run bar:foo() will now no longer provide a deprecation warning, however the function description and other relevant type-related info seems to still be supplied on-hover.

Overriding the type of bar to no longer use an intersection will restore the deprecation warning, as also seen in the code example.

This issue also appears to apply to the setmetatable type function (and potentially other operators)

1 Like

Good catch. We’re investigating. Thx for reporting.

2 Likes

Hey there! Thanks for the report, and apologies for how much time has passed! I’ve found some time to be able to revise the linter here, an upcoming release should feature a much more robust version of the Deprecated API lint that is still raised when using unions, intersections, setmetatable, and arbitrary combinations thereof.

Circling back again, this update went out and the fixes should be on everywhere. Thanks for the report!

1 Like