You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is using 'hg update release' on MacOS X Lion (hg update default and ./all.bash fail
early on).
Based on the package documentation I believe that data can be transfered to and from an
interface-typed variable. This does not seem to be the case.
The attached program can be run with the arguments ss is si ii to select a transfer from
and to a struct or an interface. Additionally, the argument reg will register the
structure with gob, but that does not change anything.
What steps will reproduce the problem?
1. compile the attached file
2. run it with options ss and is -- no error message.
3. run it with options si or ii -- error message from gob.
What is the expected output?
No error message in case 3.
What do you see instead?
decoding error gob: wrong type received for local value main.Mer: Foo = struct { Bar
string; Beque string; }
Which compiler are you using (5g, 6g, 8g, gccgo)?
6g
Which operating system are you using?
MacOS X Lion
Which revision are you using? (hg identify)
c1702f36df03 (release-branch.r60) release/release.r60.3
Hi,
I think your test case is not doing what you think it is.
Specifically, if you pass an interface { Foo() } to a function
expecting an interface{}, it is the concrete value that gets
passed to the function, dressed as an interface{}. It is not
the interface { Foo() } that gets passed inside the interface{}.
So when you say Encode(m), that's no different from Encode's
point of view than Encode(&Foo...). If you were to try
Encode(&m), that would pass a *M (pointer to interface)
inside the interface{}, and gob would invoke its interface
encoding routines. The same would happen if the interface
were inside a struct somewhere. That should be enough
to make the ii case work, provided you do the registration too.
I don't believe the is or si cases are valid; at the least I don't
think they will do what you expect. (They will do nothing,
or return an error.) Gob requires that interfaces be matched
to interfaces during the round trip.
Russ
by axel.schreiner:
Attachments:
The text was updated successfully, but these errors were encountered: