diff --git a/doc/extensions.html b/doc/extensions.html index 55c4b704..7379041d 100644 --- a/doc/extensions.html +++ b/doc/extensions.html @@ -373,6 +373,7 @@ LuaJIT supports some extensions from Lua 5.3:
  • Unicode escape '\u{XX...}' embeds the UTF-8 encoding in string literals.
  • The argument table arg can be read (and modified) by LUA_INIT and -e chunks.
  • io.read() and file:read() accept formats with or without a leading *.
  • +
  • assert() accepts any type of error object.
  • table.move(a1, f, e, t [,a2]).
  • coroutine.isyieldable().
  • Lua/C API extensions: diff --git a/src/lib_base.c b/src/lib_base.c index d61e8762..1cd83058 100644 --- a/src/lib_base.c +++ b/src/lib_base.c @@ -42,13 +42,13 @@ LJLIB_ASM(assert) LJLIB_REC(.) { - GCstr *s; lj_lib_checkany(L, 1); - s = lj_lib_optstr(L, 2); - if (s) - lj_err_callermsg(L, strdata(s)); - else + if (L->top == L->base+1) lj_err_caller(L, LJ_ERR_ASSERT); + else if (tvisstr(L->base+1) || tvisnumber(L->base+1)) + lj_err_callermsg(L, strdata(lj_lib_checkstr(L, 2))); + else + lj_err_run(L); return FFH_UNREACHABLE; }