aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/ext_ffi_semantics.html5
-rw-r--r--src/lj_carith.c4
-rw-r--r--src/lj_crecord.c16
3 files changed, 19 insertions, 6 deletions
diff --git a/doc/ext_ffi_semantics.html b/doc/ext_ffi_semantics.html
index 2dbe41e9..304befa7 100644
--- a/doc/ext_ffi_semantics.html
+++ b/doc/ext_ffi_semantics.html
@@ -724,6 +724,11 @@ of them is an <tt>uint64_t</tt>, the other side is converted to an
724both sides are converted to an <tt>int64_t</tt> and a signed 724both sides are converted to an <tt>int64_t</tt> and a signed
725comparison is performed.</li> 725comparison is performed.</li>
726 726
727<li><b>Comparisons for equality/inequality</b> never raise an error.
728Even incompatible pointers can be compared for equality by address. Any
729other incompatible comparison (also with non-cdata objects) treats the
730two sides as unequal.</li>
731
727</ul> 732</ul>
728 733
729<h3 id="cdata_key">cdata objects as table keys</h3> 734<h3 id="cdata_key">cdata objects as table keys</h3>
diff --git a/src/lj_carith.c b/src/lj_carith.c
index 56708bf6..583a3876 100644
--- a/src/lj_carith.c
+++ b/src/lj_carith.c
@@ -205,6 +205,10 @@ static int lj_carith_meta(lua_State *L, CTState *cts, CDArith *ca, MMS mm)
205 if (!tv) { 205 if (!tv) {
206 const char *repr[2]; 206 const char *repr[2];
207 int i; 207 int i;
208 if (mm == MM_eq) { /* Equality checks never raise an error. */
209 setboolV(L->top-1, 0);
210 return 1;
211 }
208 for (i = 0; i < 2; i++) { 212 for (i = 0; i < 2; i++) {
209 if (ca->ct[i]) 213 if (ca->ct[i])
210 repr[i] = strdata(lj_ctype_repr(L, ctype_typeid(cts, ca->ct[i]), NULL)); 214 repr[i] = strdata(lj_ctype_repr(L, ctype_typeid(cts, ca->ct[i]), NULL));
diff --git a/src/lj_crecord.c b/src/lj_crecord.c
index 81ab3540..74d62d6c 100644
--- a/src/lj_crecord.c
+++ b/src/lj_crecord.c
@@ -1073,13 +1073,17 @@ static void crec_arith_meta(jit_State *J, CTState *cts, RecordFFData *rd)
1073 tv = lj_ctype_meta(cts, argv2cdata(J, J->base[1], &rd->argv[1])->typeid, 1073 tv = lj_ctype_meta(cts, argv2cdata(J, J->base[1], &rd->argv[1])->typeid,
1074 (MMS)rd->data); 1074 (MMS)rd->data);
1075 } 1075 }
1076 if (tv && tvisfunc(tv)) { 1076 if (tv) {
1077 J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; 1077 if (tvisfunc(tv)) {
1078 rd->nres = -1; /* Pending tailcall. */ 1078 J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME;
1079 } else { 1079 rd->nres = -1; /* Pending tailcall. */
1080 /* NYI: non-function metamethods. */ 1080 return;
1081 lj_trace_err(J, LJ_TRERR_BADTYPE); 1081 } /* NYI: non-function metamethods. */
1082 } else if ((MMS)rd->data == MM_eq) {
1083 J->base[0] = TREF_FALSE;
1084 return;
1082 } 1085 }
1086 lj_trace_err(J, LJ_TRERR_BADTYPE);
1083} 1087}
1084 1088
1085void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd) 1089void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)