Skip to content

Commit f048adb

Browse files
add builtin function name to error
1 parent 55b1f3c commit f048adb

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/method.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ JL_DLLEXPORT jl_method_t* jl_method_def(jl_svec_t *argdata,
12991299
}
13001300
ft = jl_rewrap_unionall(ft, argtype);
13011301
if (!external_mt && !jl_has_empty_intersection(ft, (jl_value_t*)jl_builtin_type)) // disallow adding methods to Any, Function, Builtin, and subtypes, or Unions of those
1302-
jl_error("cannot add methods to a builtin function");
1302+
jl_errorf("cannot add methods to a builtin function `%s`", jl_symbol_name(name));
13031303

13041304
m = jl_new_method_uninit(module);
13051305
m->external_mt = (jl_value_t*)external_mt;

test/core.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,13 +2661,16 @@ struct D14919 <: Function; end
26612661
@test B14919()() == "It's a brand new world"
26622662
@test C14919()() == D14919()() == "Boo."
26632663

2664-
let ex = ErrorException("cannot add methods to a builtin function")
2664+
let ex_t = ErrorException, ex_r = r"cannot add methods to a builtin function"
26652665
for f in (:(Core.Any), :(Core.Function), :(Core.Builtin), :(Base.Callable), :(Union{Nothing,F} where F), :(typeof(Core.getfield)), :(Core.IntrinsicFunction))
2666-
@test_throws ex @eval (::$f)() = 1
2666+
@test_throws ex_t @eval (::$f)() = 1
2667+
@test_throws ex_r @eval (::$f)() = 1
26672668
end
2668-
@test_throws ex @eval (::Union{Nothing,F})() where {F<:Function} = 1
2669+
@test_throws ex_t @eval (::Union{Nothing,F})() where {F<:Function} = 1
2670+
@test_throws ex_r @eval (::Union{Nothing,F})() where {F<:Function} = 1
26692671
for f in (:(Core.getfield),)
2670-
@test_throws ex @eval $f() = 1
2672+
@test_throws ex_t @eval $f() = 1
2673+
@test_throws ex_r @eval $f() = 1
26712674
end
26722675
end
26732676

0 commit comments

Comments
 (0)