Skip to content

Type checker widens number into number? when multiple assignment is involved with a function call #2153

@melindatrace

Description

@melindatrace

I expect variable b to remain number in all three function variants (fa, fb, and fc).

--!strict

local function n(x: number): number return x end

local function fa(x: number): (number, number)
	local a, b = 0, 0
	for i = 1, x do
		a, b = x, n(b * a)
	end
	return a, b -- number, number?
end

local function fb(x: number): (number, number)
	local a, b = 0, 0
	for i = 1, x do
		a = x
		b = n(b * a)
	end
	return a, b -- number, number
end

local function fc(x: number): (number, number)
	local a, b = 0, 0
	for i = 1, x do
		a, b = x, b * a
	end
	return a, b -- number, number
end

Luau 0.703 (new solver)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions