diff --git a/src/ffi.c b/src/ffi.c index f5915a05..3804a261 100644 --- a/src/ffi.c +++ b/src/ffi.c @@ -1281,11 +1281,19 @@ static B ptrty_simplify(B x) { return x; } static bool ptrty_equal(B a, B b) { + assert(isC32(a) || v(a)->type==t_ffiType); + assert(isC32(b) || v(b)->type==t_ffiType); if (!isC32(a)) a = ptrty_simplify(a); - if (a.u == m_c32(sty_ptr).u) return true; + if (a.u == m_c32(sty_void).u) return true; if (!isC32(b)) b = ptrty_simplify(b); - if (b.u == m_c32(sty_ptr).u) return true; + if (b.u == m_c32(sty_void).u) return true; + + if (a.u == b.u) return true; + // TODO get rid of sty_ptr and this, represent as cty_ptr(sty_void) + if (a.u == m_c32(sty_ptr).u) return !isC32(b) && c(BQNFFIType,b)->ty==cty_ptr; // both being sty_ptr is handled by the preceding a.u == b.u + if (b.u == m_c32(sty_ptr).u) return !isC32(a) && c(BQNFFIType,a)->ty==cty_ptr; + if (isC32(a) || isC32(b)) return a.u==b.u; // if only one is a character, this test trivially fails BQNFFIType* at = c(BQNFFIType,a); diff --git a/test/cases/ffi.bqn b/test/cases/ffi.bqn index 642c0a98..fe310cc0 100644 --- a/test/cases/ffi.bqn +++ b/test/cases/ffi.bqn @@ -253,6 +253,9 @@ 1 %USE TyEq ⟨"{i32:i8,i64}", "{i32,i64}"⟩ 1 %USE TyEq ⟨"*i32:i8", "*"⟩ 1 %USE TyEq ⟨"*i32:i8", "*:c32"⟩ +0 %USE TyEq ⟨"**", "*i8"⟩ +0 %USE TyEq ⟨"*{*}", "*{i8}"⟩ +0 %USE TyEq ⟨"*{i8}", "*{*}"⟩ # !"FFI: Unimplemented result type" % @•FFI"*i32"‿"bqn_init"