Skip to content

Commit

Permalink
vm_x64.dasc: Fix FORL type coercion
Browse files Browse the repository at this point in the history
Commit fa02289 had accidentally removed
necessary code from the FORI/FORL bytecode that handles converting the
arguments to numbers. This cased breakage in code like:

    for i = "1", 3 do ... end

where an argument needs to be converted from string to number.
  • Loading branch information
lukego committed Mar 17, 2017
1 parent f458d9e commit 170c3ac
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/vm_x64.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -3935,10 +3935,15 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
vk = (op == BC_IFORL || op == BC_JFORL);
| ins_AJ // RA = base, RD = target (after end of loop or start of loop)
| lea RA, [BASE+RA*8]
if (!vk) {
| checknumtp FOR_IDX, ->vmeta_for
| checknumtp FOR_STOP, ->vmeta_for
} else {
#ifdef LUA_USE_ASSERT
| checknumtp FOR_STOP, ->assert_bad_for_arg_type
| checknumtp FOR_STEP, ->assert_bad_for_arg_type
| checknumtp FOR_STOP, ->assert_bad_for_arg_type
| checknumtp FOR_STEP, ->assert_bad_for_arg_type
#endif
}
| mov RB, FOR_STEP
if (!vk) {
| checknum RB, ->vmeta_for
Expand Down

0 comments on commit 170c3ac

Please sign in to comment.