From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 0C86725E11 for ; Fri, 26 Jul 2019 18:17:55 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dvgEjqHL0YbG for ; Fri, 26 Jul 2019 18:17:54 -0400 (EDT) Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id C17DE25DFE for ; Fri, 26 Jul 2019 18:17:54 -0400 (EDT) Received: by mail-lj1-f195.google.com with SMTP id h10so52895114ljg.0 for ; Fri, 26 Jul 2019 15:17:54 -0700 (PDT) From: Cyrill Gorcunov Subject: [tarantool-patches] [PATCH 3/3] box/console: Test for nil value in args directly Date: Sat, 27 Jul 2019 01:17:12 +0300 Message-Id: <20190726221712.11191-4-gorcunov@gmail.com> In-Reply-To: <20190726221712.11191-1-gorcunov@gmail.com> References: <20190726221712.11191-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tml Cc: Alexander Turenko , Konstantin Osipov , Cyrill Gorcunov Instead of allocating a variable for optional args testing we should use dot notation instead. Otherwise it won't work for trivial test case as ``` require('console').set_default_output('lua,block') require('decimal').new('1234.5678') ``` | builtin/box/console.lua:47: expected decimal, number or string as 2 argument and program exits. Part-of #3834 --- src/box/lua/console.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua index 0c521b44a..64086cf5b 100644 --- a/src/box/lua/console.lua +++ b/src/box/lua/console.lua @@ -41,10 +41,9 @@ output_handlers["yaml"] = function(status, opts, ...) end output_handlers["lua"] = function(status, opts, ...) - local data = ... -- -- Don't print nil if there is no data - if data == nil then + if not ... then return "" end -- -- 2.20.1