diff --git a/src/ffi.c b/src/ffi.c index 4a2ac77c..42f210d1 100644 --- a/src/ffi.c +++ b/src/ffi.c @@ -609,7 +609,7 @@ FORCE_INLINE u64 i64abs(i64 x) { return x<0?-x:x; } for (usz i=0; ia[0].o; assert(t2->ty==cty_ptr && (isC32(ore) || ore.u==ty_voidptr.u)); @@ -795,7 +795,7 @@ void genObj(B o, B c, bool anyMut, void* ptr) { // doesn't consume; mutates ffiO ffiObjsGlobal = vec_addN(ffiObjsGlobal, cG); } } else if (t->ty==cty_struct || t->ty==cty_starr) { - if (!isArr(c)) thrM("FFI: Expected array corresponding to a struct"); + if (!isArr(c)) thrF("FFI: Expected array corresponding to %R", ty_fmt(o)); if (IA(c)!=t->ia-1) thrF("FFI: Incorrect list length corresponding to %S: expected %s, got %s", t->ty==cty_struct? "a struct" : "an array", (usz)(t->ia-1), IA(c)); SGetU(c) for (usz i = 0; i < t->ia-1; i++) { diff --git a/test/cases/ffi.bqn b/test/cases/ffi.bqn index e6307abd..ac15dc90 100644 --- a/test/cases/ffi.bqn +++ b/test/cases/ffi.bqn @@ -138,8 +138,9 @@ # wrong argument internal structure !"FFI: Expected array or pointer object corresponding to ""*[2]i32""" % f←@•FFI""‿"bqn_init"‿">*[2]i32" ⋄ F @ !"FFI: Expected array or pointer object corresponding to ""*{...}""" % f←@•FFI""‿"bqn_init"‿">*{i32}" ⋄ F @ -!"FFI: Expected array corresponding to a struct" % f←@•FFI""‿"bqn_init"‿">{i32}" ⋄ F @ -!"FFI: Expected array corresponding to a struct" % f←@•FFI""‿"bqn_init"‿">*{i32}" ⋄ F ⟨@⟩ +!"FFI: Expected array corresponding to ""{...}""" % f←@•FFI""‿"bqn_init"‿">{i32}" ⋄ F 0 +!"FFI: Expected array corresponding to ""{...}""" % f←@•FFI""‿"bqn_init"‿">*{i32}" ⋄ F ⟨0⟩ +!"FFI: Expected array corresponding to ""[1]i32""" % f←@•FFI""‿"bqn_init"‿">*[1]i32" ⋄ F ⟨0⟩ !"FFI: Incorrect list length corresponding to a struct: expected 1, got 0" % f←@•FFI""‿"bqn_init"‿">*{i32}" ⋄ F ⟨⟨⟩⟩ !"FFI: Incorrect list length corresponding to a struct: expected 1, got 2" % f←@•FFI""‿"bqn_init"‿">*{i32}" ⋄ F ⟨1‿2⟩ !"FFI: Incorrect list length corresponding to an array: expected 2, got 0" % f←@•FFI""‿"bqn_init"‿">*[2]i32" ⋄ F ⟨⟨⟩⟩