Skip to content

Commit

Permalink
Make argument mismatch in opaque closure a MethodError (#41206)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Keno committed Jun 24, 2021
1 parent d0bbd4c commit ed4c44f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/opaque_closure.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ JL_CALLABLE(jl_f_opaque_closure_call)
jl_opaque_closure_t* oc = (jl_opaque_closure_t*)F;
jl_value_t *argt = jl_tparam0(jl_typeof(oc));
if (!jl_tupletype_length_compat(argt, nargs))
jl_error("Incorrect argument count for OpaqueClosure");
jl_method_error(F, args, nargs + 1, oc->world);
argt = jl_unwrap_unionall(argt);
assert(jl_is_datatype(argt));
jl_svec_t *types = jl_get_fieldtypes((jl_datatype_t*)argt);
Expand Down
2 changes: 2 additions & 0 deletions test/opaque_closure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,5 @@ function f_oc_noinline_call(x, y)
return f_oc_noinline(x)(y)
end
@test f_oc_noinline_call(1, 2) == 3

@test_throws MethodError (@opaque x->x+1)(1, 2)

2 comments on commit ed4c44f

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your package evaluation job has completed - possible new issues were detected. A full report can be found here. cc @maleadt

Please sign in to comment.