Returning on same line as yield call directly in protected mode ends breakpoint

Using the Lua debugger’s breakpoints to step through a function called in protected mode, if the function returns on the same line as a yield call, it will cause the breakpoint to cancel. Code execution will continue normally, but the breakpoint will have ended. The debugger will work as normal for future breakpoints, however.

A good reason to fix this is when returning the results of web service calls that may error directly, this will occur, and it is non-obvious what triggered the bug.

Example code, set a breakpoint at line 1 and use Step Into for all of these:

This won’t work:

pcall(function()
	return wait()
end)

print("Breakpoint won't ever reach here, but this will execute")

This will work:

pcall(function()
	local x, y = wait()
        return x, y
end)

print("Breakpoint works!")

This won’t work:

pcall(function()
	local x, y = wait() return x, y
end)

print("Breakpoint ends, but this code executes.")

This will work:

function name() -- must define function like this or you'll trigger a separate bug.
     return wait()
end

name()
print("Breakpoint works.")

This will work:

function name() -- must define function like this or you'll trigger a separate bug.
     local x, y = wait() return x, y
end

name()
print("Breakpoint works.")
1 Like