mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 14:25:44 +08:00
97965c7c0a
* `ClassType` can now have an indexer defined on it. This allows custom types to be used in `t[x]` expressions. * Fixed search for closest executable breakpoint line. Previously, breakpoints might have been skipped in `else` blocks at the end of a function * Fixed how unification is performed for two optional types `a? <: b?`, previously it might have unified either 'a' or 'b' with 'nil'. Note that this fix is not enabled by default yet (see the list in `ExperimentalFlags.h`) In the new type solver, a concept of 'Type Families' has been introduced. Type families can be thought of as type aliases with custom type inference/reduction logic included with them. For example, we can have an `Add<T, U>` type family that will resolve the type that is the result of adding two values together. This will help type inference to figure out what 'T' and 'U' might be when explicit type annotations are not provided. In this update we don't define any type families, but they will be added in the near future. It is also possible for Luau embedders to define their own type families in the global/environment scope. Other changes include: * Fixed scope used to find out which generic types should be included in the function generic type list * Fixed a crash after cyclic bound types were created during unification And in native code generation (jit): * Use of arm64 target on M1 now requires macOS 13 * Entry into native code has been optimized. This is especially important for coroutine call/pcall performance as they involve going through a C call frame * LOP_LOADK(X) translation into IR has been improved to enable type tag/constant propagation * arm64 can use integer immediate values to synthesize floating-point values * x64 assembler removes duplicate 64bit numbers from the data section to save space * Linux `perf` can now be used to profile native Luau code (when running with --codegen-perf CLI argument)
86 lines
1.4 KiB
Lua
86 lines
1.4 KiB
Lua
-- This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
print "testing debugger" -- note, this file can't run in isolation from C tests
|
|
|
|
local a = 5
|
|
|
|
function foo(b, ...)
|
|
print("in foo", b)
|
|
a = 6
|
|
end
|
|
|
|
breakpoint(8)
|
|
|
|
foo(50, 42)
|
|
|
|
breakpoint(16) -- next line
|
|
print("here")
|
|
|
|
function coro(arg)
|
|
print("before coro break")
|
|
a = arg
|
|
print("after coro break")
|
|
return 42
|
|
end
|
|
|
|
breakpoint(20) -- break inside coro()
|
|
|
|
a = 7
|
|
|
|
local co = coroutine.create(coro)
|
|
local _, res = coroutine.resume(co, 8) -- this breaks and resumes!
|
|
assert(res == 42)
|
|
|
|
local cof = coroutine.wrap(coro)
|
|
assert(cof(9) == 42) -- this breaks and resumes!
|
|
|
|
function corobad()
|
|
print("before coro break")
|
|
error("oops")
|
|
end
|
|
|
|
assert(a == 9)
|
|
|
|
breakpoint(38) -- break inside corobad()
|
|
|
|
local co = coroutine.create(corobad)
|
|
assert(coroutine.resume(co) == false) -- this breaks, resumes and dies!
|
|
|
|
function bar()
|
|
print("in bar")
|
|
end
|
|
|
|
breakpoint(49)
|
|
breakpoint(49, false) -- validate that disabling breakpoints works
|
|
|
|
bar()
|
|
|
|
local function breakpointSetFromMetamethod()
|
|
local a = setmetatable({}, {
|
|
__index = function()
|
|
breakpoint(67)
|
|
return 2
|
|
end
|
|
})
|
|
|
|
local b = a.x
|
|
|
|
assert(b == 2)
|
|
end
|
|
|
|
breakpointSetFromMetamethod()
|
|
|
|
-- break inside function with non-monotonic line info
|
|
local function cond(a)
|
|
if a then
|
|
print('a')
|
|
else
|
|
print('not a')
|
|
end
|
|
end
|
|
|
|
breakpoint(77)
|
|
|
|
pcall(cond, nil) -- prevent inlining
|
|
|
|
return 'OK'
|