[Tarantool-patches] [PATCH luajit] Add stricter check for print() vs. tostring() shortcut.

Igor Munkin imun at tarantool.org
Thu Jun 30 15:09:38 MSK 2022


Sergey,

I've checked the patch into all long-term branches in tarantool/luajit
and bumped a new version in master, 2.10 and 1.10.

On 27.12.21, Sergey Kaplun wrote:
> From: Mike Pall <mike>
> 
> (cherry picked from 46a1b268eb0534182eda0447303c344a071632fe)
> 
> `print()` function uses tostring to convert all incoming values to the
> strings. So, if element to convert has `__tostring` metamethod it must
> be used. In LuaJIT `print()` base library function has a shortcut to
> detect fast path for strings and numbers. This shortcut doesn't check
> metatable presence for numbers, so `__tostring` metamethod is ignored.
> 
> This patch adds the corresponding check for metatable on base number
> type, when the aforementioned shortcut is set.
> 
> Sergey Kaplun:
> * added the description and the test for the problem
> 
> Part of tarantool/tarantool#6548
> ---
> 
> Issue: https://github.com/tarantool/tarantool/issues/6548
> Related issue: https://github.com/tarantool/tarantool/issues/6746
> 
> Branch: https://github.com/tarantool/luajit/tree/skaplun/gh-noticket-print-tostring-number-mt-full-ci
> Tarantool branch: https://github.com/tarantool/tarantool/tree/skaplun/gh-noticket-print-tostring-number-mt-full-ci
> 
> CI is red due to integration tests failes (same as on master) or due to
> connection errors.
> 
>  src/lib_base.c                                |  3 +-
>  .../print-tostring-number.test.lua            | 45 +++++++++++++++++++
>  2 files changed, 47 insertions(+), 1 deletion(-)
>  create mode 100644 test/tarantool-tests/print-tostring-number.test.lua
> 

<snipped>

> -- 
> 2.34.1
> 

-- 
Best regards,
IM


More information about the Tarantool-patches mailing list