'luaD_seterrorobj' should not raise errors

This function can be called unprotected, so it should not raise any
kind of errors. (It could raise a memory-allocation error when creating
a message).
This commit is contained in:
Roberto Ierusalimschy
2025-03-12 15:51:16 -03:00
parent d9e0f64a5d
commit c931d86e98
5 changed files with 25 additions and 22 deletions

View File

@@ -46,7 +46,7 @@ end
assert(doit("error('hi', 0)") == 'hi')
-- test nil error message
assert(doit("error()") == "<error object is nil>")
assert(doit("error()") == "<no error object>")
-- test common errors/errors that crashed in the past
@@ -614,7 +614,7 @@ do
assert(not res and msg == t)
res, msg = pcall(function () error(nil) end)
assert(not res and msg == "<error object is nil>")
assert(not res and msg == "<no error object>")
local function f() error{msg='x'} end
res, msg = xpcall(f, function (r) return {msg=r.msg..'y'} end)