diff --git a/base/reflection.jl b/base/reflection.jl index 36b8ad34a2314..c81471b0801ef 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -160,7 +160,7 @@ function _subtypes(m::Module, x::DataType, sts=Set(), visited=Set()) push!(visited, m) for s in names(m,true) if isdefined(m,s) - t = eval(m,s) + t = getfield(m, s) if isa(t, DataType) && t.name.name == s && supertype(t).name == x.name ti = typeintersect(t, x) ti != Bottom && push!(sts, ti) diff --git a/base/replutil.jl b/base/replutil.jl index edbc2863e53a9..478b8cfe4c3e8 100644 --- a/base/replutil.jl +++ b/base/replutil.jl @@ -267,7 +267,7 @@ function showerror(io::IO, ex::MethodError) name = ft.name.mt.name f_is_function = false kwargs = Any[] - if startswith(string(ft.name), "#kw#") + if startswith(string(ft.name.name), "#kw#") f = ex.args[2] ft = typeof(f) name = ft.name.mt.name diff --git a/test/replutil.jl b/test/replutil.jl index c0a34b29df5e9..e44ef80ddee1b 100644 --- a/test/replutil.jl +++ b/test/replutil.jl @@ -95,14 +95,31 @@ m_error = try method_c6(1, x=1) catch e; e; end showerror(buf, m_error) error_out1 = takebuf_string(buf) +module TestKWError +method_c6_in_module(; x=1) = x +method_c6_in_module(a; y=1) = y +end +m_error = try TestKWError.method_c6_in_module(y=1) catch e; e; end +showerror(buf, m_error) +error_out2 = takebuf_string(buf) +m_error = try TestKWError.method_c6_in_module(1, x=1) catch e; e; end +showerror(buf, m_error) +error_out3 = takebuf_string(buf) + if Base.have_color @test contains(error_out, "method_c6(; x)\e[1m\e[31m got an unsupported keyword argument \"y\"\e[0m") @test contains(error_out, "method_c6(\e[1m\e[31m::Any\e[0m; y)") @test contains(error_out1, "method_c6(::Any; y)\e[1m\e[31m got an unsupported keyword argument \"x\"\e[0m") + @test contains(error_out2, "method_c6_in_module(; x)\e[1m\e[31m got an unsupported keyword argument \"y\"\e[0m") + @test contains(error_out2, "method_c6_in_module(\e[1m\e[31m::Any\e[0m; y)") + @test contains(error_out3, "method_c6_in_module(::Any; y)\e[1m\e[31m got an unsupported keyword argument \"x\"\e[0m") else @test contains(error_out, "method_c6(; x) got an unsupported keyword argument \"y\"") @test contains(error_out, "method_c6(!Matched::Any; y)") @test contains(error_out1, "method_c6(::Any; y) got an unsupported keyword argument \"x\"") + @test contains(error_out2, "method_c6_in_module(; x) got an unsupported keyword argument \"y\"") + @test contains(error_out2, "method_c6_in_module(!Matched::Any; y)") + @test contains(error_out3, "method_c6_in_module(::Any; y) got an unsupported keyword argument \"x\"") end method_c7(a, b; kargs...) = a