-
Notifications
You must be signed in to change notification settings - Fork 11
Description
julia> BangBang.push!!(:a, 0, identity, "haha")
4-element Vector{Any}:
:a
Symbol("[0]")
identity (generic function with 5 methods)
"haha"I think the above should result in a MethodError saying a Symbol is not a collection, you can't push!! to it. The current behaviour caused us some trouble in https://github.com/TuringLang/DynamicPPL.jl/ by resulting in a hard to understand downstream error, when we were accidentally calling push!! with the wrong arguments.
The cause of the current behaviour is that push!! falls back on push, which has this method:
push(xs, x) = vcat(xs, singletonof(xs, x))and it turns out you can vcat all sorts of nonsense like this:
julia> vcat(:a, [0.2])
2-element Vector{Any}:
:a
0.2I think it's questionable whether the above behaviour by vcat is desirable, but it's a bit more understandable since at least one expects an array from a vcat call, where as getting a Vector of stuff when calling push!! on a bunch of arguments none of which is a Vector is quite surprising.