Type 'true' could not be converted into 'false'

I came across a strange issue today saying that “Type ‘true’ could not be converted into ‘false’” in strict mode.

I am using the Luau type checker beta and --!strict mode.

Code sample:

export type CharacterReplicationServer = {
	_started: boolean;
} & typeof(CharacterReplicationServer)

function CharacterReplicationServer.Start(self: CharacterReplicationServer)
	if self._started == true then
		return
	end
	
	self._started = true
end

Expected behavior

I expected no luau typechecker warning.

A private message is associated with this bug report

1 Like

Hi there, thank you for the report! This is indeed a bug in the New Type Solver. Specifically, self._started == true as a condition is producing a type refinement after the branch that self._started is not true. This refinement is useful since if you tried to read self._started, you’d be able to know that the type is always false at that point. The bug is that this refinement is also mistakenly being applied to self._started when it’s being written (the jargon is “in lvalue position”). We’ll take a look at fixing it as soon as possible!

4 Likes

I am having this bug too
image

1 Like