diff options
| author | Mike Pall <mike> | 2018-06-05 12:23:56 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2018-06-05 12:23:56 +0200 |
| commit | a5a89ab586a3b5bb4f266949bbf3dc2b140e2374 (patch) | |
| tree | 6743ee80ead7f7a78d1caf9df45921f549c1250e | |
| parent | 55f70823242aa4e6acc248bde5cf8194ba1b27e3 (diff) | |
| download | luajit-a5a89ab586a3b5bb4f266949bbf3dc2b140e2374.tar.gz luajit-a5a89ab586a3b5bb4f266949bbf3dc2b140e2374.tar.bz2 luajit-a5a89ab586a3b5bb4f266949bbf3dc2b140e2374.zip | |
From Lua 5.3: assert() accepts any type of error object.
| -rw-r--r-- | doc/extensions.html | 1 | ||||
| -rw-r--r-- | src/lib_base.c | 10 |
2 files changed, 6 insertions, 5 deletions
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: | |||
| 373 | <li>Unicode escape <tt>'\u{XX...}'</tt> embeds the UTF-8 encoding in string literals.</li> | 373 | <li>Unicode escape <tt>'\u{XX...}'</tt> embeds the UTF-8 encoding in string literals.</li> |
| 374 | <li>The argument table <tt>arg</tt> can be read (and modified) by <tt>LUA_INIT</tt> and <tt>-e</tt> chunks.</li> | 374 | <li>The argument table <tt>arg</tt> can be read (and modified) by <tt>LUA_INIT</tt> and <tt>-e</tt> chunks.</li> |
| 375 | <li><tt>io.read()</tt> and <tt>file:read()</tt> accept formats with or without a leading <tt>*</tt>.</li> | 375 | <li><tt>io.read()</tt> and <tt>file:read()</tt> accept formats with or without a leading <tt>*</tt>.</li> |
| 376 | <li><tt>assert()</tt> accepts any type of error object.</li> | ||
| 376 | <li><tt>table.move(a1, f, e, t [,a2])</tt>.</li> | 377 | <li><tt>table.move(a1, f, e, t [,a2])</tt>.</li> |
| 377 | <li><tt>coroutine.isyieldable()</tt>.</li> | 378 | <li><tt>coroutine.isyieldable()</tt>.</li> |
| 378 | <li>Lua/C API extensions: | 379 | <li>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 @@ | |||
| 42 | 42 | ||
| 43 | LJLIB_ASM(assert) LJLIB_REC(.) | 43 | LJLIB_ASM(assert) LJLIB_REC(.) |
| 44 | { | 44 | { |
| 45 | GCstr *s; | ||
| 46 | lj_lib_checkany(L, 1); | 45 | lj_lib_checkany(L, 1); |
| 47 | s = lj_lib_optstr(L, 2); | 46 | if (L->top == L->base+1) |
| 48 | if (s) | ||
| 49 | lj_err_callermsg(L, strdata(s)); | ||
| 50 | else | ||
| 51 | lj_err_caller(L, LJ_ERR_ASSERT); | 47 | lj_err_caller(L, LJ_ERR_ASSERT); |
| 48 | else if (tvisstr(L->base+1) || tvisnumber(L->base+1)) | ||
| 49 | lj_err_callermsg(L, strdata(lj_lib_checkstr(L, 2))); | ||
| 50 | else | ||
| 51 | lj_err_run(L); | ||
| 52 | return FFH_UNREACHABLE; | 52 | return FFH_UNREACHABLE; |
| 53 | } | 53 | } |
| 54 | 54 | ||
