Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an error hint for min/max on an iterable #52716

Merged
merged 4 commits into from Jan 9, 2024

Conversation

KristofferC
Copy link
Sponsor Member

Inspired by the discussion in https://discourse.julialang.org/t/max-of-a-vector/108294/15

julia> max([1,2,3])
ERROR: MethodError: no method matching max(::Vector{Int64})
Finding the minimum or maximum element of an array is performed with `minimum` and `maximum` respectively.
....

julia> max([1,2,3])
ERROR: MethodError: no method matching max(::Vector{Int64})
Finding the minimum or maximum element of an array is performed with `minimum` and `maximum` respectively.
....

@KristofferC KristofferC added the domain:error messages Better, more actionable error messages label Jan 3, 2024
@stevengj
Copy link
Member

stevengj commented Jan 3, 2024

Should there be a test?

base/errorshow.jl Outdated Show resolved Hide resolved
@aplavin
Copy link
Contributor

aplavin commented Jan 4, 2024

Wow, errorhints are great!
Maybe also add another direction? For

julia> maximum(1,2,3)
ERROR: MethodError: no method matching maximum(::Int64, ::Int64, ::Int64)

base/errorshow.jl Outdated Show resolved Hide resolved
@KristofferC KristofferC changed the title add an error hint for min/max on an array add an error hint for min/max on an iterable Jan 8, 2024
@KristofferC KristofferC merged commit 4b64203 into master Jan 9, 2024
5 of 7 checks passed
@KristofferC KristofferC deleted the kc/min_max_array_errorhint branch January 9, 2024 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:error messages Better, more actionable error messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants