Skip to content

replace! on a string gives an unfriendly internal error #57613

Open
@IanButterworth

Description

@IanButterworth
julia> str = "abc";

julia> replace!(str, "a" => "1")
ERROR: MethodError: no method matching _replace!(::Base.var"#new#replace_pairs!##0"{Tuple{Pair{String, String}}}, ::String, ::String, ::Int64)
The function `_replace!` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  _replace!(::Union{Function, Type}, ::Set{T}, ::AbstractSet, ::Int64) where T
   @ Base set.jl:985
  _replace!(::Union{Function, Type}, ::Dict{K, V}, ::AbstractDict, ::Int64) where {K, V}
   @ Base set.jl:953
  _replace!(::Union{Function, Type}, ::AbstractArray, ::AbstractArray, ::Int64)
   @ Base set.jl:920
  ...

Stacktrace:
 [1] replace_pairs!(res::String, A::String, count::Int64, old_new::Tuple{Pair{String, String}})
   @ Base ./set.jl:745
 [2] replace!(A::String, old_new::Pair{String, String}; count::Int64)
   @ Base ./set.jl:735
 [3] top-level scope
   @ REPL[18]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    error messagesBetter, more actionable error messagesstrings"Strings!"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions