Autocomplete type is incorrect on refined types

In the following example code, maybeNumber is typed as number after the type refinement:

--!strict
local function foo()
	local example: number = 0
	local maybeNumber: number? = nil

	if not maybeNumber then
		return
	end

	example = maybeNumber
end

This is shown to be true as no type error (from strict mode) is shown when the variable is fully written out, and hovering over maybeNumber in the assignment correctly shows maybeNumber: number.

However, the autocomplete when typing out maybeNumber incorrectly describes it as number?.
This has caused me, and I’m sure others, confusion many times.

This happens on both the old & new Luau type solvers, and I’m on macOS running Version 0.706.0.7060750 (arm64).

Expected behavior

I expect that the box to the right of the autocomplete list correctly displays number after a type refinement.

Hello! Yeah that’s definitely weird. It may be intended behavior, but we’ll try to dig in and see if we can do something better here.