Skip to content

Type refinements should not apply to lvalues. #1651

@HarmosCreations

Description

@HarmosCreations
function public:Heal(timer:number)
	
	local self :Healing = self
	
	if (self.Healing == true) then return end
	
	self.Healing = true

--Type 'true' could not be converted into '~true'; type true (true) is not a subtype of ~true.negated() (true) Warning 1
--Type 'true' could not be converted into '~~(false?)'; type true (true) is not a subtype of ~~(false?).negated() (~(false?)) Warning 2
--both warnings comming from self.Healing = true 
-- i also don't know why the warning went from ~true to ~~false just reloaded the script
        

        .....
        self.Healing = false

--if i change the if statement to not self.Healing

        self.Healing = false -- Type 'false' could not be converted into '~(false?)'; type false (false) is not a subtype of ~(false?).negated() (false?)

function new:
local self = setmetatable({}, {__index=module}
self.Healing = false :: boolean

i have met this issue a lot if statements have the power to change the meaning of a variable in some cases it's good but in some other cases it is annoying.

is there a way to go around this or is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnew solverThis issue is specific to the new solver.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions