luau-lang / luau

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

`buffer` library doesn't accept `buffer`s in new type solver's non-strict mode #1267

Closed Ketasaja closed 1 month ago

Ketasaja commented 1 month ago
local b = buffer.create(100)
buffer.writef64(b, 0, 5) -- TypeError: Function 'buffer.writef64' expects 'buffer' at argument #0, but got 'buffer'
buffer.readi8(b, 0) -- TypeError: Function 'buffer.readi8' expects 'buffer' at argument #0, but got 'buffer'

Tested on 0.627, with no errors when using strict mode.

alexmccord commented 1 month ago

Thanks for catching this! Fix for this is coming in the next sync.

Ketasaja commented 1 month ago

@alexmccord I found a similar issue with function parameters, with 0.628.0 in non-strict mode:

local function _(b: buffer) -- TypeError: Argument b with type 'unknown' in function '_' is used in a way that will run time error
    buffer.writeu32(b, 0, 0)
end
alexmccord commented 1 month ago

Can you open a new issue for that?