From 170c3ac7a985d21290cdf4e12bbc29191a872cb5 Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Fri, 17 Mar 2017 15:00:02 +0000 Subject: [PATCH] vm_x64.dasc: Fix FORL type coercion Commit fa02289da662f714ebf7a2c5586a4adf1adbe106 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. --- src/vm_x64.dasc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/vm_x64.dasc b/src/vm_x64.dasc index 6fdf941d8d..f85927af54 100644 --- a/src/vm_x64.dasc +++ b/src/vm_x64.dasc @@ -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