Studio Bugs: Function with intersection type parameter incorrectly interpreting unions as intersections

Declaring a type as an intersection of one type with another can result in impossible types being created when accepting this type as a parameter of a function.

This happens only in Studio with --!strict.
I am unsure of when this issue started.

Repro

Create a script with the following code:

--!strict
type A = {}
type B = A&{
	Value: string|boolean
}
local function C(self: B): nil
	self.Value = true; --Typecheck error: "Type 'boolean' could not be converted into 'boolean & string'"
	return;
end

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.

2 Likes

Hey, thanks for the report! We flipped on a flag that fixes this bug.

2 Likes