]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
FFI: Add tonumber() specialization for failed conversions.
authorMike Pall <mike>
Sun, 22 Apr 2018 11:27:25 +0000 (13:27 +0200)
committerMike Pall <mike>
Sun, 22 Apr 2018 11:27:25 +0000 (13:27 +0200)
Contributed by Javier Guerra Giraldez.

src/lj_crecord.c

index 84fc49ee19214ed87b4bfa3f3edc2a84b347d5b6..bc88d635cafcb4fcdc6264ffc2e3c5ef0eac7ee9 100644 (file)
@@ -1661,6 +1661,8 @@ void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd)
       d = ctype_get(cts, CTID_DOUBLE);
     J->base[0] = crec_ct_tv(J, d, 0, J->base[0], &rd->argv[0]);
   } else {
+    /* Specialize to the ctype that couldn't be converted. */
+    argv2cdata(J, J->base[0], &rd->argv[0]);
     J->base[0] = TREF_NIL;
   }
 }