Skip to content

Commit 0848394

Browse files
KenoKristofferC
authored andcommitted
Make argument mismatch in opaque closure a MethodError (#41206)
This at least shows the argument types. In the future we may want to add some logic to the errorshow code to improve this even further, but good enough for now.
1 parent 9bee745 commit 0848394

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/opaque_closure.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ JL_CALLABLE(jl_f_opaque_closure_call)
7676
jl_opaque_closure_t* oc = (jl_opaque_closure_t*)F;
7777
jl_value_t *argt = jl_tparam0(jl_typeof(oc));
7878
if (!jl_tupletype_length_compat(argt, nargs))
79-
jl_error("Incorrect argument count for OpaqueClosure");
79+
jl_method_error(F, args, nargs + 1, oc->world);
8080
argt = jl_unwrap_unionall(argt);
8181
assert(jl_is_datatype(argt));
8282
jl_svec_t *types = jl_get_fieldtypes((jl_datatype_t*)argt);

test/opaque_closure.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,5 @@ function f_oc_noinline_call(x, y)
204204
return f_oc_noinline(x)(y)
205205
end
206206
@test f_oc_noinline_call(1, 2) == 3
207+
208+
@test_throws MethodError (@opaque x->x+1)(1, 2)

0 commit comments

Comments
 (0)