luau-lang / luau

A fast, small, safe, gradually typed embeddable scripting language derived from Lua
https://luau.org
MIT License
3.98k stars 373 forks source link

`and` `or` expression causes type pack error with new type solver's strict mode #1271

Closed Ketasaja closed 2 months ago

Ketasaja commented 4 months ago

Tested on 0.627 with no errors in non-strict mode.

--!strict
local function _(): string
    if true then
        return table.concat({} :: {[any]: any}, true and "" or "") -- TypeError: Type pack '*blocked-tp-285*' could not be converted into 'string'; type *blocked-tp-285*.tail() (*blocked-tp-285*) is not a subtype of string (string)
    else
        return table.concat({} :: {[any]: any}, if true then "" else "")
    end
end

local function __(): {string}
    if true then
        return string.split("", true and "" or "") -- TypeError: Type pack '*blocked-tp-958*' could not be converted into '{string}'; type *blocked-tp-958*.tail() (*blocked-tp-958*) is not a subtype of {string} ({string})
    else
        return string.split("", if true then "" else "")
    end
end
Ketasaja commented 2 months ago

Fixed as of 0.635.