Skip to content

Commit

Permalink
Don't show string concatenation error hint with zero arg + (#55749)
Browse files Browse the repository at this point in the history
Closes #55745
  • Loading branch information
christiangnrd authored Sep 12, 2024
1 parent 945517b commit 8a9f384
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ Experimental.register_error_hint(nonsetable_type_hint_handler, MethodError)
# (probably attempting concatenation)
function string_concatenation_hint_handler(io, ex, arg_types, kwargs)
@nospecialize
if (ex.f === +) && all(i -> i <: AbstractString, arg_types)
if (ex.f === +) && !isempty(arg_types) && all(i -> i <: AbstractString, arg_types)
print(io, "\nString concatenation is performed with ")
printstyled(io, "*", color=:cyan)
print(io, " (See also: https://docs.julialang.org/en/v1/manual/strings/#man-concatenation).")
Expand Down
6 changes: 6 additions & 0 deletions test/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,12 @@ let err_str
@test occursin("String concatenation is performed with *", err_str)
end

# https://github.com/JuliaLang/julia/issues/55745
let err_str
err_str = @except_str +() MethodError
@test !occursin("String concatenation is performed with *", err_str)
end

struct MissingLength; end
struct MissingSize; end
Base.IteratorSize(::Type{MissingSize}) = Base.HasShape{2}()
Expand Down

0 comments on commit 8a9f384

Please sign in to comment.