What happens is that vrw is *ValueStore and snd is *database, where snd.ValueStore == vrw. IOW, the database's ValueStore gets unwrapped somewhere along the line and used for vrw.
This kind of accidental unwrapping is common, and usually happens by calling a method on the embedded field. That's what happens to us too:
That call is where the ValueStore gets unwrapped and eventually passed through to the new value.
This all said, I don't think there's anything actually wrong here other than the bad assertion. It's not valid to assume that if two ValueReadWriter values are non-equal that they wrap different database instances.
Also, I don't think this assertion is particularly needed, since it is just a special case of doing anything (except diff and sync) with values from different databases.
I have a blob that crashes like so:
The crash is here:
https://github.com/attic-labs/noms/blob/master/go/types/sequence_concat.go#L24
What happens is that
vrw
is*ValueStore
andsnd
is*database
, wheresnd.ValueStore == vrw
. IOW, the database'sValueStore
gets unwrapped somewhere along the line and used forvrw
.This kind of accidental unwrapping is common, and usually happens by calling a method on the embedded field. That's what happens to us too:
concat()
callschunker.Done()
: https://github.com/attic-labs/noms/blob/master/go/types/sequence_concat.go#L43getChildSequence()
: https://github.com/attic-labs/noms/blob/master/go/types/sequence_chunker.go#L267getChildSequence
dereferences a ref, which can callValueStore.readValue()
: https://github.com/attic-labs/noms/blob/master/go/types/meta_sequence.go#L68That call is where the
ValueStore
gets unwrapped and eventually passed through to the new value.This all said, I don't think there's anything actually wrong here other than the bad assertion. It's not valid to assume that if two
ValueReadWriter
values are non-equal that they wrap different database instances.Also, I don't think this assertion is particularly needed, since it is just a special case of doing anything (except diff and sync) with values from different databases.