From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id C05C56ECE3; Thu, 14 Jul 2022 14:33:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C05C56ECE3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1657798409; bh=B04KA59uq+jYMi6BnP41IkwEMBKTAwsWHu6C3TuzVB0=; h=In-Reply-To:Date:References:To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=XG7I3FxQA2x95vMmfNZ/0KzJfnYiXBypqIFDHvqlv35ftqhJzVl5Rcj46EdR01V5o f/Qq9kCzAnb1nnglvOLJOX2SChX8raY7HzrNeb8gc9ojwNCzrICWv12GxWTvFaCGdQ iDHghIw9NnzOj0wQWDrMUEP3K/2zm18MEyamTxBs= Received: from smtp56.i.mail.ru (smtp56.i.mail.ru [217.69.128.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 010676ECE3 for ; Thu, 14 Jul 2022 14:33:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 010676ECE3 Received: by smtp56.i.mail.ru with esmtpa (envelope-from ) id 1oBx5z-0007B1-8Q; Thu, 14 Jul 2022 14:33:27 +0300 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) In-Reply-To: <20220713064149.523-1-skaplun@tarantool.org> Date: Thu, 14 Jul 2022 14:33:26 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20220713064149.523-1-skaplun@tarantool.org> To: Sergey Kaplun X-Mailer: Apple Mail (2.3696.100.31) X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9E1E7861EDEC0DEA6E6C8A145894E5FE5392863A383C2480D00894C459B0CD1B9718E98D343E8E0BCB32A09DB77D8B2A8DCAFF5E356A15DC028006A18B89A766B X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72F22E6DC541F75D9EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637DDCE02C19EA0BA868638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8801278B6B218456957DD188C1E6514AE117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC07EE6BD9D908E34E389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC82FFDA4F57982C5F4F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C4B1E592663965C8BC0837EA9F3D197644AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C37CB2176D36798DBBBA3038C0950A5D36B5C8C57E37DE458B0BC6067A898B09E46D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE71878E14E9E518603731C566533BA786AA5CC5B56E945C8DA X-8FC586DF: 6EFBBC1D9D64D975 X-C1DE0DAB: 9604B64F49C60606AD91A466A1DEF99B296C473AB1E142185AC9E3593CE4B31AB1881A6453793CE9274300E5CE05BD4401A9E91200F654B06604ACF793451CC5EEDD2DF4914E7A12C3E209476EE488A7F055054FF98C9BEE9C2B6934AE262D3EE7EAB7254005DCED8DA55E71E02F9FC08E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3429538671E6527D325259CA4141D52FECEE6819F8F3358325E2DB97B96D6D825B0295DCCCC2129B4A1D7E09C32AA3244C29EF93054DAE1A10C5F04F5FE88239C83FD9C8CA1B0515E0FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojpV6+aF9js39Etrk+Ufj51g== X-Mailru-Sender: 5AA3D5B9D8C486460F131602D6A791BC4A7D3D1641F1ED7E9BAE1E2F5172B6FB6B71F02B504FC27919381EE24192DF5555834048F03EF5D4C9A814A92B2E3B1BA4250FC3964EA4964198E0F3ECE9B5443453F38A29522196 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] From Lua 5.3: assert() accepts any type of error object. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: sergos via Tarantool-patches Reply-To: sergos Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thanks for the patch! Minor updates, LGTM. Sergos > On 13 Jul 2022, at 09:41, Sergey Kaplun wrote: >=20 > From: Mike Pall >=20 > (cherry picked from commit a5a89ab586a3b5bb4f266949bbf3dc2b140e2374) >=20 > This patch removes type restrictions for the second optional argument = in ^ all? > `assert()` function. It allows to use different error objects in ^^^^^^^^ various > `assert()` and catches them via `pcall()`. ^^^^^^^^ to catch >=20 > Sergey Kaplun: > * added the description and the test for the problem >=20 > Part of tarantool/tarantool#7230 > --- >=20 > Branch: = https://github.com/tarantool/luajit/tree/skaplun/lj-418-assert-any-type-fu= ll-ci > Issue: https://github.com/LuaJIT/LuaJIT/issues/418 >=20 > doc/extensions.html | 1 + > src/lib_base.c | 10 +++++----- > .../lj-418-assert-any-type.test.lua | 14 ++++++++++++++ > 3 files changed, 20 insertions(+), 5 deletions(-) > create mode 100644 = test/tarantool-tests/lj-418-assert-any-type.test.lua >=20 > diff --git a/doc/extensions.html b/doc/extensions.html > index d7cc9693..e0f136e2 100644 > --- a/doc/extensions.html > +++ b/doc/extensions.html > @@ -374,6 +374,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 613a1859..83c7663c 100644 > --- a/src/lib_base.c > +++ b/src/lib_base.c > @@ -42,13 +42,13 @@ >=20 > LJLIB_ASM(assert) LJLIB_REC(.) > { > - GCstr *s; > lj_lib_checkany(L, 1); > - s =3D lj_lib_optstr(L, 2); > - if (s) > - lj_err_callermsg(L, strdata(s)); > - else > + if (L->top =3D=3D 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; > } >=20 > diff --git a/test/tarantool-tests/lj-418-assert-any-type.test.lua = b/test/tarantool-tests/lj-418-assert-any-type.test.lua > new file mode 100644 > index 00000000..37b88574 > --- /dev/null > +++ b/test/tarantool-tests/lj-418-assert-any-type.test.lua > @@ -0,0 +1,14 @@ > +local tap =3D require('tap') > + > +-- See also https://github.com/LuaJIT/LuaJIT/issues/418. > +local test =3D tap.test('lj-418-asset-any-type') > +test:plan(1) > + > +local retv =3D {} > + > +local st, obj =3D pcall(assert, false, retv) > +assert(not st, 'pcall fails') > + > +test:ok(obj =3D=3D retv, 'assert function take non-string argument') Shall we add an xpcall case also? tarantool> xpcall(assert, function(s) print('Handled:', s) end, false, = {'catch me!'}) Handled: table: 0x01022dc810 --- - false - null ... > + > +os.exit(test:check() and 0 or 1) > --=20 > 2.34.1 >=20