Skip to content

Commit

Permalink
Merge pull request #363 from orisano/fix/#359
Browse files Browse the repository at this point in the history
fix: to care about the case of OpInterfacePtr
  • Loading branch information
goccy authored Apr 21, 2022
2 parents 171d975 + 6db1acf commit 337d02f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions decode_test.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 337d02f

Please sign in to comment.