julia
79fb4e93 - suggest candidate methods on typename wrapper when parameterized call has no methods (#61700)

Commit
138 days ago
suggest candidate methods on typename wrapper when parameterized call has no methods (#61700) inspired by new-user confusion I've seen on discourse, example https://discourse.julialang.org/t/scope-of-parametric-types-and-associated-error-messages/48928 ```julia julia> struct Foo{T} x::T Foo(x) = new{typeof(x)}(x) end # master julia> Foo{Int}(1) ERROR: MethodError: no method matching Foo{Int64}(::Int64) The type `Foo{Int64}` exists, but no method is defined for this combination of argument types when trying to construct it. Stacktrace: [1] top-level scope @ REPL[1]:1 # PR julia> Foo{Int}(1) ERROR: MethodError: no method matching Foo{Int64}(::Int64) The type `Foo{Int64}` exists, but no method is defined for this combination of argument types when trying to construct it. Closest candidates are: Foo(::Any) @ Main REPL[1]:3 Stacktrace: [1] top-level scope @ REPL[1]:1 ``` this might be a little controversial since we're technically lying to the user (it is a method on a different type than the one they passed) but given that it would condition it only on `isempty(methods(f))` it seems useful to me
Author
Parents
Loading