mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-12 21:10:37 +00:00
9c588be16d
# What's changed? * Check interrupt handler inside the pattern match engine to eliminate potential for programs to hang during string library function execution. * Allow iteration over table properties to pass the old type solver. ### Native Code Generation * Use in-place memory operands for math library operations on x64. * Replace opaque bools with separate enum classes in IrDump to improve code maintainability. * Translate operations on inferred vectors to IR. * Enable support for debugging native-compiled functions in Roblox Studio. ### New Type Solver * Rework type inference for boolean and string literals to introduce bounded free types (bounded below by the singleton type, and above by the primitive type) and reworked primitive type constraint to decide which is the appropriate type for the literal. * Introduce `FunctionCheckConstraint` to handle bidirectional typechecking for function calls, pushing the expected parameter types from the function onto the arguments. * Introduce `union` and `intersect` type families to compute deferred simplified unions and intersections to be employed by the constraint generation logic in the new solver. * Implement support for expanding the domain of local types in `Unifier2`. * Rework type inference for iteration variables bound by for in loops to use local types. * Change constraint blocking logic to use a set to prevent accidental re-blocking. * Add logic to detect missing return statements in functions. ### 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: 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>
111 lines
1.8 KiB
Lua
111 lines
1.8 KiB
Lua
-- This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
print("testing interrupts")
|
|
|
|
-- this function will be called by C code with a special interrupt handler that validates hit locations
|
|
function test()
|
|
function foo()
|
|
for i=1,10 do end
|
|
return
|
|
end
|
|
|
|
foo()
|
|
|
|
function bar()
|
|
local i = 0
|
|
while i < 10 do
|
|
i += i + 1
|
|
end
|
|
end
|
|
|
|
bar()
|
|
|
|
function baz()
|
|
end
|
|
|
|
baz()
|
|
end
|
|
|
|
-- these functions will be called by C code with a special interrupt handler that terminates after a few invocations
|
|
function infloop1()
|
|
while true do end
|
|
end
|
|
|
|
function infloop2()
|
|
while true do continue end
|
|
end
|
|
|
|
function infloop3()
|
|
repeat until false
|
|
end
|
|
|
|
function infloop4()
|
|
repeat continue until false
|
|
end
|
|
|
|
function infloop5()
|
|
for i=0,0,0 do end
|
|
end
|
|
|
|
function infloop6()
|
|
for i=0,0,0 do continue end
|
|
end
|
|
|
|
function infloop7()
|
|
for i=1,math.huge do end
|
|
end
|
|
|
|
function infloop8()
|
|
for i=1,math.huge do continue end
|
|
end
|
|
|
|
function infloop9()
|
|
-- technically not a loop, but an exponentially recursive function
|
|
local function boom()
|
|
boom()
|
|
boom()
|
|
end
|
|
boom()
|
|
end
|
|
|
|
function infloop10()
|
|
for l0=4096,0,0 do
|
|
repeat
|
|
continue
|
|
until function<t0>() end
|
|
end
|
|
end
|
|
|
|
local haystack = string.rep("x", 100)
|
|
local pattern = string.rep("x?", 100) .. string.rep("x", 100)
|
|
|
|
function strhang1()
|
|
string.find(haystack, pattern)
|
|
end
|
|
|
|
function strhang2()
|
|
string.match(haystack, pattern)
|
|
end
|
|
|
|
function strhang3()
|
|
string.gsub(haystack, pattern, "%0")
|
|
end
|
|
|
|
function strhang4()
|
|
for k, v in string.gmatch(haystack, pattern) do
|
|
end
|
|
end
|
|
|
|
function strhang5()
|
|
local x = string.rep('x', 1000)
|
|
string.match(x, string.rep('x.*', 100) .. 'y')
|
|
end
|
|
|
|
function strhangpcall()
|
|
for i = 1,100 do
|
|
local status, msg = pcall(string.find, haystack, pattern)
|
|
assert(status == false)
|
|
assert(msg == "timeout")
|
|
end
|
|
end
|
|
|
|
return "OK"
|