Tarantool discussions archive
 help / color / mirror / Atom feed
* [Tarantool-discussions] Implicit cast for assignment between numeric types and type mismatch error description.
@ 2020-06-22 11:52 Mergen Imeev
  2020-06-22 18:43 ` Peter Gulutzan
  0 siblings, 1 reply; 6+ messages in thread
From: Mergen Imeev @ 2020-06-22 11:52 UTC (permalink / raw)
  To: pgulutzan, tarantool-discussions, korablev, Vladislav Shpilevoy, tsafin

Hello Peter!

I have two questions.

The first. I am sorry to ask about this again, but I want to
discuss once again the implicit cast for assignment between
numeric types. I wrote earlier that I plan to use C rules for
implicit casting. However, after implementation, this looks
terribly wrong for me. Temporarily, I decided to allow implicit
casting only if the number after conversion from one type to
another using C rules and back remains unchanged. For example, a
double 50.0 can be implicitly cast to an integer 50, but a
double 50.5 cannot be cast to an integer, and an integer 2^60-1
cannot be cast to a double.

However, I am not sure if this is correct. Could you suggest rules
for implicit casting to assign numeric types?

The second question is about type mismatch error text.

We currently have two types of type mismatch errors.

The first:
- 'Type mismatch: can not convert some_text to integer'

The second:
- 'Type mismatch: can not convert text to integer'

In the first case, we use the value in the error description, in
the second we use the type.

Now we have decided on the same opinion.

We have 3 options:
1) use value in error description:
Type mismatch: can not convert 'some_text' to integer
2) use type in error description:
Type mismatch: can not convert text to integer
3) use both in error description:
Type mismatch: can not convert 'some_text'(text) to integer

The first and third options look a little unsafe, since the values
​​will be shown in the logs. However, they provide more information
than the second option.

Which one do you think is the best? Or maybe you can offer another
option?

In addition, we must remember that at some point the description
becomes the same as in Lua (issue #5074):
'Tuple field 1 type does not match one required by operation:
expected integer'

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-25 19:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22 11:52 [Tarantool-discussions] Implicit cast for assignment between numeric types and type mismatch error description Mergen Imeev
2020-06-22 18:43 ` Peter Gulutzan
2020-06-23 16:15   ` Mergen Imeev
2020-06-23 19:42     ` Peter Gulutzan
2020-06-25  8:02       ` Mergen Imeev
2020-06-25 19:39         ` Peter Gulutzan

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