Tarantool development patches archive
 help / color / mirror / Atom feed
From: Oleg Babin <olegrok@tarantool.org>
To: tarantool-patches@freelists.org,
	Kirill Yukhin <kyukhin@tarantool.org>,
	tarantool-patches@dev.tarantool.org
Cc: Oleg Babin <babinoleg@mail.ru>
Subject: Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH] error: Add __concat method to error object
Date: Mon, 11 Nov 2019 17:43:26 +0300	[thread overview]
Message-ID: <fa9b79a7-4fb6-7260-1db0-916fad82a0ee@tarantool.org> (raw)
In-Reply-To: <20191024062150.uzuct2lkmrix3cne@tarantool.org>

Hello, thank you for review!


I will add test in second version of patch.

> Hello,
>
> On 22 окт 16:14, Kirill Yukhin wrote:
> Why do you prohibit rhs to be nil. If needed, should we also disable
> box.NULL?
>

We expect that error will have behavior as usual string then we should
prohibit

using of nils and box.NULLs:


```


tarantool> 'simple string' .. nil
---
- error: '[string "return ''simple string'' .. nil"]:1: attempt to
concatenate a nil
    value'
...

tarantool> 'simple string' .. box.NULL
---
- error: '[string "return ''simple string'' .. box.NULL"]:1: attempt to
concatenate
    ''string'' and ''void *'''
...


```

In this case "attempt to concatenate struct error and nil" will be returned


On 24/10/2019 09:21, Kirill Yukhin wrote:
> Hello,
>
> On 22 окт 16:14, Kirill Yukhin wrote:
>> From: Oleg Babin <babinoleg@mail.ru>
>>
>> Usually functions return pair {nil, err} and expected that err is string.
>> Let's make the behaviour of error object closer to string
>> and define __concat metamethod.
>>
>> Closes tarantool/tarantool#4489
>> ---
>>  src/lua/error.lua | 8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/src/lua/error.lua b/src/lua/error.lua
>> index 28fc0377d..b44fab7b6 100644
>> --- a/src/lua/error.lua
>> +++ b/src/lua/error.lua
>> @@ -150,9 +150,17 @@ local function error_index(err, key)
>>      return error_methods[key]
>>  end
>>  
>> +local function error_concat(lhs, rhs)
>> +    if lhs == nil or rhs == nil then
>> +        error("attempt to concatenate struct error and nil")
>> +    end
> Why do you prohibit rhs to be nil. If needed, should we also disable
> box.NULL?
>
> Why you didn't add a test?
>
> --
> Regards, Kirill Yukhin
>
--

Oleg Babin

           reply	other threads:[~2019-11-11 14:43 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20191024062150.uzuct2lkmrix3cne@tarantool.org>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fa9b79a7-4fb6-7260-1db0-916fad82a0ee@tarantool.org \
    --to=olegrok@tarantool.org \
    --cc=babinoleg@mail.ru \
    --cc=kyukhin@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH] error: Add __concat method to error object' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox