-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Labels
error messagesBetter, more actionable error messagesBetter, more actionable error messagesgood first issueIndicates a good issue for first-time contributors to JuliaIndicates a good issue for first-time contributors to Julia
Description
I ran across this unhelpful error message
julia> vec = [1, 2, 3]
3-element Vector{Int64}:
1
2
3
julia> vec[1+1]
2
julia> vec[1+ 1]
2
julia> vec[1 + 1]
2
julia> vec[1 +1]
ERROR: MethodError: no method matching typed_hcat(::Vector{Int64}, ::Int64, ::Int64)
Closest candidates are:
typed_hcat(::Type{T}, ::Number...) where T
@ Base abstractarray.jl:1614
typed_hcat(::Type{T}, ::Union{Number, LinearAlgebra.Adjoint{T, <:AbstractVector} where T}...) where T
@ LinearAlgebra ~/.julia/juliaup/julia-1.9.0-rc3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.9/LinearAlgebra/src/adjtrans.jl:352
typed_hcat(::Type{T}, ::Union{Number, LinearAlgebra.Transpose{T, <:AbstractVector} where T}...) where T
@ LinearAlgebra ~/.julia/juliaup/julia-1.9.0-rc3+0.aarch64.apple.darwin14/share/julia/stdlib/v1.9/LinearAlgebra/src/adjtrans.jl:353
...
Stacktrace:
[1] top-level scope
@ REPL[54]:1
This is because typed comprehensions Float64[1 2]
and array access vec[3]
share the same syntax. Giving a hint when the "type" used in a typed comprehension is not a type and is an indexable object might help.
timholy, mzy2240 and t-bltg
Metadata
Metadata
Assignees
Labels
error messagesBetter, more actionable error messagesBetter, more actionable error messagesgood first issueIndicates a good issue for first-time contributors to JuliaIndicates a good issue for first-time contributors to Julia