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

3 Likes

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

2 Likes

Hi there, thank you for the report! We have this issue in a few different places in our backlog right now, and an engineer planning to work on it very soon. In the interest of keeping things better organized though, I’ll be closing this out as a dupe. Please don’t hesitate to report any further issues you encounter!

1 Like

Hello! We have recently deployed a fix here, and this error should no longer occur. Please let us know if you have any further questions or concerns.

And, as always, thank you for beta testing the new Luau type solver!

1 Like

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