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

fix: to care about the case of OpInterfacePtr #363

Merged
merged 1 commit into from Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions decode_test.go
Expand Up @@ -3918,3 +3918,16 @@ func TestIssue360(t *testing.T) {
t.Errorf("unexpected result: %v", uints)
}
}

func TestIssue359(t *testing.T) {
var a interface{} = 1
var b interface{} = &a
var c interface{} = &b
v, err := json.Marshal(c)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if string(v) != "1" {
t.Errorf("unexpected result: %v", string(v))
}
}
2 changes: 1 addition & 1 deletion internal/encoder/opcode.go
Expand Up @@ -363,7 +363,7 @@ func copyOpcode(code *Opcode) *Opcode {

func setTotalLengthToInterfaceOp(code *Opcode) {
for c := code; !c.IsEnd(); {
if c.Op == OpInterface {
if c.Op == OpInterface || c.Op == OpInterfacePtr {
c.Length = uint32(code.TotalLength())
}
c = c.IterNext()
Expand Down