Typechecker flags nill-able variables despite using a Guard-Clause

Description

Using either Non-Strict or Strict Typechecking, the Typechecker will falsely warn about nill-able variables when using guard-clauses.

Repro

--!nonstrict
local Baseplate: Part? = workspace.Baseplate

function foo()
	if Baseplate then
		Baseplate.Anchored = false -- Okay
	end
	
	if not Baseplate then return end
	Baseplate.Anchored = false -- Value of 'Part?' could be nil
end

Expected Behavior

Since Guard-Clauses are a common code pattern, I expect the Typechecker to respect nill-ables when they are applied.

We’ve filed a ticket to our internal database, and we’ll follow up when we have an update.

Thanks for flagging!

1 Like

@MagmaBurnsV – the issue is fixed on our side (see luau note above), are you still experiencing it?

1 Like

This has been fixed, thank you!

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