fix diff for 32bit arrays - #21
Conversation
Teo-ShaoWei
left a comment
There was a problem hiding this comment.
I would be hesitant to add in a specific hack for vectors. Effectively :(variable_name[index]) is Expr(:ref, :variable_name, index) and so there's a potential regression point. Most importantly, we will open a can of worms as we now need to cater for vectors of different container types but same inner values...
| if e.head === :ref && isa(e.args, Vector) | ||
| return true | ||
| end | ||
| return false |
There was a problem hiding this comment.
Since e::Expr, we have isa(e.args, Vector) to always be true. So the following suffice
| if e.head === :ref && isa(e.args, Vector) | |
| return true | |
| end | |
| return false | |
| return e.head === :ref |
|
Just a note: this fix is for arrays of any type that is not listed here—not just 32bit arrays. For example: julia> string([true, true])
"Bool[1, 1]"When julia> Meta.parse(string([true, false]))
:(Bool[1, 0])
julia> Meta.parse(string([true, false])).head
:ref
julia> Meta.parse(string([true, false])).args
3-element Vector{Any}:
:Bool
1
0 |
| if e.head === :vect | ||
| return true | ||
| end | ||
| #Float32 or Int32 arrays get here as Ref's to Vector |
There was a problem hiding this comment.
And this is not quite true. The arrays get here with the same syntax as a Ref, but they're not actually a ref to a vector. Just a bit of a confusing overlap in the display of vectors and the syntax for Refs.
Fixes #20