mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-13 13:30:40 +00:00
68bd1b2349
# What's changed? * Improved the actual message for the type errors for `cannot call non-function` when attempting to call a union of functions/callable tables. The error now correctly explains the issue is an inability to determine the return type of the call in this situation. * Resolve an issue where tables and metatables were not correctly being cloned during instantiation (fixes #1176). * Refactor `luaM_getnextgcopage` to `luaM_getnextpage` (generally removing `gco` prefix where appropriate). * Optimize `table.move` between tables for large ranges of elements. * Reformat a bunch of code automatically using `clang-format`. ### New Type Solver * Clean up minimally-used or unused constraints in the constraint solver (`InstantiationConstraint`, `SetOpConstraint`, `SingletonOrTopTypeConstraint`). * Add a builtin `singleton` type family to replace `SingletonOrTopTypeConstraint` when inferring refinements. * Fixed a crash involving type path reasoning by recording when type family reduction has taken place in the path. * Improved constraint ordering by blocking on unreduced types families that are not yet proven uninhabitable. * Improved the handling of `SetIndexerConstraints` for both better inference quality and to resolve crashes. * Fix a crash when normalizing cyclic unions of intersections. * Fix a crash when normalizing an intersection with the negation of `unknown`. * Fix a number of crashes caused by missing `follow` calls on `TypeId`s. * Changed type family reduction to correctly use a semantic notion of uninhabited types, rather than checking for `never` types specifically. * Refactor the `union` and `intersect` type families to be variadic. ### Native Code Generation * Improve translation for userdata key get/set and userdata/vector namecall. * Provide `[top level]` and `[anonymous]` as function names to `FunctionStats` as appropriate when no function name is available. * Disable unwind support on Android platforms since it is unsupported. * --- ### Internal Contributors Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Vighnesh <vvijay@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: David Cope <dcope@roblox.com> Co-authored-by: Lily Brown <lbrown@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
112 lines
3.5 KiB
Lua
112 lines
3.5 KiB
Lua
-- This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
-- This file is based on Lua 5.x tests -- https://github.com/lua/lua/tree/master/testes
|
|
local function checkerror (msg, f, ...)
|
|
local s, err = pcall(f, ...)
|
|
assert(not s and string.find(err, msg))
|
|
end
|
|
|
|
print("testing move")
|
|
|
|
local maxI = 2147483647
|
|
local minI = -2147483648
|
|
|
|
-- testing move
|
|
do
|
|
|
|
checkerror("table expected", table.move, 1, 2, 3, 4)
|
|
checkerror("table expected", table.move, {}, 2, 3, 4, "foo")
|
|
|
|
local function eqT (a, b)
|
|
for k, v in pairs(a) do assert(b[k] == v) end
|
|
for k, v in pairs(b) do assert(a[k] == v) end
|
|
end
|
|
|
|
local a = table.move({10,20,30}, 1, 3, 2) -- move forward
|
|
eqT(a, {10,10,20,30})
|
|
|
|
-- move forward with overlap of 1
|
|
a = table.move({10, 20, 30}, 1, 3, 3)
|
|
eqT(a, {10, 20, 10, 20, 30})
|
|
|
|
-- moving to the same table (not being explicit about it)
|
|
a = {10, 20, 30, 40}
|
|
table.move(a, 1, 4, 2, a)
|
|
eqT(a, {10, 10, 20, 30, 40})
|
|
|
|
a = table.move({10,20,30}, 2, 3, 1) -- move backward
|
|
eqT(a, {20,30,30})
|
|
|
|
a = {} -- move to new table
|
|
assert(table.move({10,20,30}, 1, 3, 1, a) == a)
|
|
eqT(a, {10,20,30})
|
|
|
|
a = {}
|
|
assert(table.move({10,20,30}, 1, 0, 3, a) == a) -- empty move (no move)
|
|
eqT(a, {})
|
|
|
|
a = table.move({10,20,30}, 1, 10, 1) -- move to the same place
|
|
eqT(a, {10,20,30})
|
|
|
|
-- moving on the fringes
|
|
a = table.move({[maxI - 2] = 1, [maxI - 1] = 2, [maxI] = 3},
|
|
maxI - 2, maxI, -10, {})
|
|
eqT(a, {[-10] = 1, [-9] = 2, [-8] = 3})
|
|
|
|
a = table.move({[minI] = 1, [minI + 1] = 2, [minI + 2] = 3},
|
|
minI, minI + 2, -10, {})
|
|
eqT(a, {[-10] = 1, [-9] = 2, [-8] = 3})
|
|
|
|
a = table.move({45}, 1, 1, maxI)
|
|
eqT(a, {45, [maxI] = 45})
|
|
|
|
a = table.move({[maxI] = 100}, maxI, maxI, minI)
|
|
eqT(a, {[minI] = 100, [maxI] = 100})
|
|
|
|
a = table.move({[minI] = 100}, minI, minI, maxI)
|
|
eqT(a, {[minI] = 100, [maxI] = 100})
|
|
|
|
-- moving small amount of elements (array/hash) using a wide range
|
|
a = {}
|
|
table.move({1, 2, 3, 4, 5}, -100000000, 100000000, -100000000, a)
|
|
eqT(a, {1, 2, 3, 4, 5})
|
|
|
|
a = {}
|
|
table.move({1, 2}, -100000000, 100000000, 0, a)
|
|
eqT(a, {[100000001] = 1, [100000002] = 2})
|
|
|
|
-- hash part copy
|
|
a = {}
|
|
table.move({[-1000000] = 1, [-100] = 2, [100] = 3, [100000] = 4}, -100000000, 100000000, 0, a)
|
|
eqT(a, {[99000000] = 1, [99999900] = 2, [100000100] = 3, [100100000] = 4})
|
|
|
|
-- precise hash part bounds
|
|
a = {}
|
|
table.move({[-100000000 - 1] = -1, [-100000000] = 1, [-100] = 2, [100] = 3, [100000000] = 4, [100000000 + 1] = -1}, -100000000, 100000000, 0, a)
|
|
eqT(a, {[0] = 1, [99999900] = 2, [100000100] = 3, [200000000] = 4})
|
|
|
|
-- no integer undeflow in corner hash part case
|
|
a = {}
|
|
table.move({[minI] = 100, [-100] = 2}, minI, minI + 100000000, minI, a)
|
|
eqT(a, {[minI] = 100})
|
|
|
|
-- hash part skips array slice
|
|
a = {}
|
|
table.move({[-1] = 1, [0] = 2, [1] = 3, [2] = 4}, -1, 3, 1, a)
|
|
eqT(a, {[1] = 1, [2] = 2, [3] = 3, [4] = 4})
|
|
|
|
a = {}
|
|
table.move({[-1] = 1, [0] = 2, [1] = 3, [2] = 4, [10] = 5, [100] = 6, [1000] = 7}, -1, 3, 1, a)
|
|
eqT(a, {[1] = 1, [2] = 2, [3] = 3, [4] = 4})
|
|
end
|
|
|
|
checkerror("too many", table.move, {}, 0, maxI, 1)
|
|
checkerror("too many", table.move, {}, -1, maxI - 1, 1)
|
|
checkerror("too many", table.move, {}, minI, -1, 1)
|
|
checkerror("too many", table.move, {}, minI, maxI, 1)
|
|
checkerror("wrap around", table.move, {}, 1, maxI, 2)
|
|
checkerror("wrap around", table.move, {}, 1, 2, maxI)
|
|
checkerror("wrap around", table.move, {}, minI, -2, 2)
|
|
|
|
checkerror("readonly", table.move, table.freeze({}), 1, 1, 1)
|
|
|
|
return"OK"
|