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 C389D6ECE3; Fri, 15 Jul 2022 12:20:17 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C389D6ECE3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1657876817; bh=KfEwI9YRurStKV4GHGNzJmN66oIBhaqHkBEq7MslvEo=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=W9hztLAi/lTh1zGl9iQpJfxUS5HeU/I9uOXIQu80JrS/29i46wZDOl3A680gzJvPp vYDlvE2r+fCRYyEOmenZvmtT6vn7Gr87MQcbOUsTU8VAI9zle+6g3nwtSRak752xpD 3XwkESgGVXQmzi88qKSkZm81ZB8eX9CmfVyQjIds= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [94.100.177.149]) (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 65A8C6ECE3 for ; Fri, 15 Jul 2022 12:20:16 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 65A8C6ECE3 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1oCHUd-0004FE-Go; Fri, 15 Jul 2022 12:20:16 +0300 Date: Fri, 15 Jul 2022 12:17:54 +0300 To: sergos Message-ID: References: <20220713064149.523-1-skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD910A510B04B6817B61491CD8592B55F8CD093714853935E8C182A05F5380850404C228DA9ACA6FE27A6D46DA3067BD691E0505E3FC1C6DB02BB13DD1BDE1C80C4D71CB45DA1B5566A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7AD2F2D6F6013FF7FC2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE757F64E7FD849EB4FEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38B8859CA687ABA27BA229C9CAD128808E523A3A6E9DA332AF1CC7F00164DA146DAFE8445B8C89999728AA50765F79006377FF6DF7F8AE7C7A6389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8062BEEFFB5F8EA3EF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8BAEB924C2B054B06E75ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-8FC586DF: 6EFBBC1D9D64D975 X-C1DE0DAB: 9604B64F49C60606AD91A466A1DEF99B296C473AB1E142185AC9E3593CE4B31AB1881A6453793CE9274300E5CE05BD4401A9E91200F654B0F56C66D0505D9834D71D610BA8056A100C69A7A3262F64DE30EE363BC29F82709C2B6934AE262D3EE7EAB7254005DCED8DA55E71E02F9FC08E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D342833AC5E8E9ACF1CCCC46A34BDD3BE04E456FF1ACA0CAE79328374DCC332EE7368FDCF48484210781D7E09C32AA3244CC39909A346810285A063FB759DC28776C3B3ADDA61883BB5FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojpf3/rFe+bF/pX/vxufmPbw== X-Mailru-Sender: 689FA8AB762F7393CC2E0F076E87284E1B3B2C04461CB681B83B79DD23AEEFFD0FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 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: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergos! Thanks for the review! On 14.07.22, sergos wrote: > Hi! > > Thanks for the patch! > > Minor updates, LGTM. > > Sergos > > > On 13 Jul 2022, at 09:41, Sergey Kaplun wrote: > > > > From: Mike Pall > > > > (cherry picked from commit a5a89ab586a3b5bb4f266949bbf3dc2b140e2374) > > > > 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 Update commit message to the following: =================================================================== >From Lua 5.3: assert() accepts any type of error object. (cherry picked from commit a5a89ab586a3b5bb4f266949bbf3dc2b140e2374) This patch removes all type restrictions for the second optional argument in `assert()` function. It allows to use various error objects in `assert()` and catch them via `pcall()` or `xpcall()`. Sergey Kaplun: * added the description and the test for the problem Part of tarantool/tarantool#7230 =================================================================== Branch is force-pushed. > > > > > Sergey Kaplun: > > * added the description and the test for the problem > > > > Part of tarantool/tarantool#7230 > > --- > > > > Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-418-assert-any-type-full-ci > > Issue: https://github.com/LuaJIT/LuaJIT/issues/418 > > > > 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 > > > > diff --git a/doc/extensions.html b/doc/extensions.html > > index d7cc9693..e0f136e2 100644 > > --- a/doc/extensions.html > > +++ b/doc/extensions.html > > 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 > > 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 = require('tap') > > + > > +-- See also https://github.com/LuaJIT/LuaJIT/issues/418. > > +local test = tap.test('lj-418-asset-any-type') > > +test:plan(1) > > + > > +local retv = {} > > + > > +local st, obj = pcall(assert, false, retv) > > +assert(not st, 'pcall fails') > > + > > +test:ok(obj == 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 > ... > I've added the following `xpcall()` case: =================================================================== diff --git a/test/tarantool-tests/lj-418-assert-any-type.test.lua b/test/tarantool-tests/lj-418-assert-any-type.test.lua index 37b88574..dba60b61 100644 --- a/test/tarantool-tests/lj-418-assert-any-type.test.lua +++ b/test/tarantool-tests/lj-418-assert-any-type.test.lua @@ -2,7 +2,7 @@ local tap = require('tap') -- See also https://github.com/LuaJIT/LuaJIT/issues/418. local test = tap.test('lj-418-asset-any-type') -test:plan(1) +test:plan(2) local retv = {} @@ -11,4 +11,8 @@ assert(not st, 'pcall fails') test:ok(obj == retv, 'assert function take non-string argument') +st = xpcall(assert, function(obj) + test:ok(obj == retv, 'xpcall error handler function get non-string argument') +end, false, retv) + os.exit(test:check() and 0 or 1) =================================================================== > > + > > +os.exit(test:check() and 0 or 1) > > -- > > 2.34.1 > > > -- Best regards, Sergey Kaplun