Skip to content

fix diff for 32bit arrays #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

dpinol
Copy link

@dpinol dpinol commented Jul 22, 2021

Fixes #20

Copy link

@Teo-ShaoWei Teo-ShaoWei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Comment on lines +65 to +68
if e.head === :ref && isa(e.args, Vector)
return true
end
return false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since e::Expr, we have isa(e.args, Vector) to always be true. So the following suffice

Suggested change
if e.head === :ref && isa(e.args, Vector)
return true
end
return false
return e.head === :ref

@ReubenJ
Copy link

ReubenJ commented May 8, 2025

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 Meta.parseing that string, the result is an expression of type :ref, too:

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

diff between arrays of Int32 or Float32 shows "nothing"
3 participants