<!DOCTYPE html>
<html data-lt-installed="true">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body style="padding-bottom: 1px;">
    <p>Hi, Sergey,</p>
    <p>LGTM</p>
    <div class="moz-cite-prefix">On 3/5/26 12:57, Sergey Kaplun wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:aalTojQh2jORvJvy@root">
      <pre wrap="" class="moz-quote-pre">Hi, Sergey!
Thanks for the review.
See my answer below.

On 04.03.26, Sergey Bronnikov wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="" class="moz-quote-pre">Hi, Sergey,

thanks for the patch!

The bug cannot be reproduced with reverted fix.

CMake: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DLUAJIT_NUMMODE=2
</pre>
      </blockquote>
      <pre wrap="" class="moz-quote-pre">
You need to enable assertions as well.</pre>
    </blockquote>
    Yep, with -DLUA_USE_ASSERT=ON it is reproduced.
    <blockquote type="cite" cite="mid:aalTojQh2jORvJvy@root">
      <pre wrap="" class="moz-quote-pre">

</pre>
      <blockquote type="cite">
        <pre wrap="" class="moz-quote-pre">Sergey

On 3/2/26 11:14, Sergey Kaplun wrote:
</pre>
        <blockquote type="cite">
          <pre wrap="" class="moz-quote-pre">From: Mike Pall <mike>

Reported by Sergey Kaplun.

(cherry picked from commit 406cf69b3ae0a3ecd5ede2bb97b937b7a5d92074)

`rec_for_loop()` narrows the FORL index values by getting them from the
runtime. In case when the `start`, `stop`, `step` control variables are
already loaded to the slots, their TRef isn't converted to the
corresponding type. This leads to the following inconsistent IR dump and
to the assertion failure later:
| 0002 > int SLOAD  10   TCI
| 0003   int ADD    0002  +1.
| 0004 > int LE     0003  +1.
| 0005   int ADD    0003  +1.
| 0006 > int GT     0005  +1.

This patch adds the missing type conversion.

Sergey Kaplun:
* added the description and the test for the problem

Part of tarantool/tarantool#12134
---

<a class="moz-txt-link-freetext" href="Branch:https://github.com/tarantool/luajit/tree/skaplun/lj-1413-missing-conv-fori">Branch:https://github.com/tarantool/luajit/tree/skaplun/lj-1413-missing-conv-fori</a>
Related issues:
*<a class="moz-txt-link-freetext" href="https://github.com/LuaJIT/LuaJIT/issues/1413">https://github.com/LuaJIT/LuaJIT/issues/1413</a>
*<a class="moz-txt-link-freetext" href="https://github.com/tarantool/tarantool/issues/12134">https://github.com/tarantool/tarantool/issues/12134</a>

</pre>
        </blockquote>
      </blockquote>
      <pre wrap="" class="moz-quote-pre">
<snipped>

</pre>
    </blockquote>
  </body>
  <lt-container></lt-container>
</html>