Skip to content

Vector setindex!! on arrays of arrays fails #44

@penelopeysm

Description

@penelopeysm
julia> x = fill(1, 2, 2)
2×2 Matrix{Int64}:
 1  1
 1  1

julia> BangBang.setindex!!(x, ["a", "a"], 1, :)
2×2 Matrix{Any}:
  "a"   "a"
 1     1

julia> y = fill([1], 2, 2)
2×2 Matrix{Vector{Int64}}:
 [1]  [1]
 [1]  [1]

julia> BangBang.setindex!!(y, ["a", "a"], 1, :)
ERROR: MethodError: Cannot `convert` an object of type
  String to an object of type
  Vector

Stacktrace:
  [1] setindex!
    @ ./array.jl:994 [inlined]
  [2] macro expansion
    @ ./multidimensional.jl:981 [inlined]
  [3] macro expansion
    @ ./cartesian.jl:64 [inlined]
  [4] _unsafe_setindex!
    @ ./multidimensional.jl:979 [inlined]
  [5] _setindex!
    @ ./multidimensional.jl:967 [inlined]
  [6] setindex!
    @ ./abstractarray.jl:1413 [inlined]
  [7] _setindex(::Matrix{Vector{Int64}}, ::Vector{String}, ::Int64, ::Function)
    @ BangBang.NoBang ~/.julia/packages/BangBang/9Z60G/src/NoBang/base.jl:135
  [8] may
    @ ~/.julia/packages/BangBang/9Z60G/src/core.jl:11 [inlined]
  [9] setindex!!(::Matrix{Vector{Int64}}, ::Vector{String}, ::Int64, ::Function)
    @ BangBang ~/.julia/packages/BangBang/9Z60G/src/base.jl:478

One would probably expect to get

2×2 Matrix{Any}:
 "a"  "a"
 [1]  [1]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions