Skip to content
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

Fixes issue 26 and 84 #90

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

Conversation

mauro3
Copy link
Contributor

@mauro3 mauro3 commented Mar 1, 2021

Hopefully correctly this time around, first take was PR #29.

Hopefully correctly this time around, first take was PR JuliaIO#29.
@@ -105,6 +105,6 @@ load(x) = raise_recursive(parse(x))

function roundtrip(x)
buf = IOBuffer()
bson(buf, Dict(:data => x))
bson(buf, BSONDict(:data => x))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once the lower was fixed, this caused another test failure.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't

bson(buf, Dict(:data => x))

not working be considered a bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The failure it caused was:

@test roundtrip_equal(T(()))

(it errored).

But note that bson(buf, Dict(:data=>x)) does work.

Copy link
Collaborator

@CarloLucibello CarloLucibello Mar 7, 2021

Choose a reason for hiding this comment

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

But note that bson(buf, Dict(:data=>x)) does work.

but it wouldn't work for x = T(()). I'm not sure about the implications but it doesn't seem safe to break this right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, you're right. Here the example:

julia> using BSON

julia> struct T{A}
         x::A
       end

julia> x = T(())
T{Tuple{}}(())

julia> buf = IOBuffer()
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=1, mark=-1)

julia> bson(buf, Dict(:data => x))

julia> BSON.load(seek(buf, 0))[:data]
ERROR: MethodError: no method matching T{Tuple{}}()
Closest candidates are:
  T{Tuple{}}(::Any) where A at REPL[2]:2

Well, you seem to have a better grasp of this than me, maybe you can take this (or something else) and fix it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't have any solutions, I'm not familiar with the internals. Let's leave this PR open hoping someone comes in with the correct solution at some point

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then the question is whether this "bug" is bigger than the bug #26. Otherwise merging this might still make sense.

@@ -1,6 +1,3 @@
lower(x::Dict{Symbol}) = BSONDict(x)
lower(x::BSONDict) = BSONDict(x)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This caused the bug seen in #84.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, its a bit of a hack, and not a very good one either.

@mauro3 mauro3 mentioned this pull request Mar 1, 2021
@mauro3
Copy link
Contributor Author

mauro3 commented Mar 1, 2021

Note sure what the test-failure is about.

One thing to consider is (and maybe test) is what happens when one wants to store a BSONDict itself. Maybe best to error on that.

As a bit of a side-note: I don't know the code of BSON at all (apart from this PR), nor have a really spent time contemplating it's design. So, I will not be very useful for anything more than band-aids.

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.

3 participants