aboutsummaryrefslogtreecommitdiff
path: root/compat53
diff options
context:
space:
mode:
authorPhilipp Janda <siffiejoe@gmx.net>2015-08-18 00:49:22 +0200
committerPhilipp Janda <siffiejoe@gmx.net>2015-08-18 00:49:22 +0200
commitdb7cb39cdd973deca26ad96d5a478a4ba1d98f30 (patch)
tree3b7716ec06cfea17e476b62ec17e3ff53a0697af /compat53
parentfb114d8dc6810133ba9e10d75fa9887ee169bf5d (diff)
downloadlua-compat-5.3-db7cb39cdd973deca26ad96d5a478a4ba1d98f30.tar.gz
lua-compat-5.3-db7cb39cdd973deca26ad96d5a478a4ba1d98f30.tar.bz2
lua-compat-5.3-db7cb39cdd973deca26ad96d5a478a4ba1d98f30.zip
assert() can handle non-string errors.
Diffstat (limited to 'compat53')
-rw-r--r--compat53/module.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/compat53/module.lua b/compat53/module.lua
index 56c9932..4450bd5 100644
--- a/compat53/module.lua
+++ b/compat53/module.lua
@@ -147,6 +147,20 @@ if lua_version < "5.3" then
147 end 147 end
148 148
149 149
150 -- assert should allow non-string error objects
151 do
152 function M.assert(cond, ...)
153 if cond then
154 return cond, ...
155 elseif select('#', ...) > 0 then
156 error((...), 0)
157 else
158 error("assertion failed!", 0)
159 end
160 end
161 end
162
163
150 -- ipairs should respect __index metamethod 164 -- ipairs should respect __index metamethod
151 do 165 do
152 local function ipairs_iterator(st, var) 166 local function ipairs_iterator(st, var)