luau-lang / luau

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

New checker: issue with `rawequal or rawequal` statement #1494

Open imnerolin opened 4 weeks ago

imnerolin commented 4 weeks ago
----- Example case:
function NOT <v> (
    v: v
): boolean
    --[[
        rawequal(v, false) or rawequal(v, nil)
        TypeError: Operator 'or' could not be applied to operands of types boolean and *blocked-22543*; there is no corresponding overload for __or
    --]]
    return rawequal(v, false) or rawequal(v, nil)
end

----- My case:
function lua.assert <v> (
    -- Added an optional level parameter for error handling.
    value: v,
    message: string?,
    level: number?
): v
    if rawequal(value, false) or rawequal(value, nil) then
        error(message or "Assertion failed!", (level or 1) + 1)
    end
    return value
end

not sure how to describe this. code works fine in old checker im new to github im not sure how to add a new checker label sorry