luau-lang / luau

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

`#` operator applied to array table is typed as boolean sometimes #1416

Closed dv-extrarius closed 2 days ago

dv-extrarius commented 1 week ago

This code under strict gets an error on the line local numRanges: number = #ranges saying that boolean can't be converted to number

local function TestFunc(ranges: {number}): {number}
    if true then
        ranges = {} :: {number}
    end
    local numRanges: number = #ranges
    return ranges
end
aatxe commented 6 days ago

Thanks for the report. This should be fixed in the 644 release. Cheers! 😸