luau icon indicating copy to clipboard operation
luau copied to clipboard

New Solver: Type '*no-refine*' could not be converted into 'string' in an invariant context

Open JohnnyMorganz opened this issue 10 months ago • 0 comments

Minimized example from https://github.com/aatxe/lute/blob/primary/batteries/json.luau

Seems to be due to the interaction with string.match

type DeserializerState = {
	src: string,
	cursor: number,
}

function deserialize_number(state: DeserializerState)
	-- ...
end

function deserialize(state: DeserializerState)
	if string.match(state.src, "^[%d%.]", state.cursor) then
		-- Errors on "state"
		-- TypeError: Type '*no-refine*' could not be converted into 'number' in an invariant context
		-- TypeError: Type '*no-refine*' could not be converted into 'string' in an invariant context
		deserialize_number(state)
	end
end

Example of the state type:

Image

JohnnyMorganz avatar Mar 02 '25 10:03 JohnnyMorganz