mirror of https://github.com/goccy/go-json.git
Merge pull request #363 from orisano/fix/#359
fix: to care about the case of OpInterfacePtr
This commit is contained in:
commit
337d02ffe6
|
@ -3918,3 +3918,16 @@ func TestIssue360(t *testing.T) {
|
||||||
t.Errorf("unexpected result: %v", uints)
|
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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -363,7 +363,7 @@ func copyOpcode(code *Opcode) *Opcode {
|
||||||
|
|
||||||
func setTotalLengthToInterfaceOp(code *Opcode) {
|
func setTotalLengthToInterfaceOp(code *Opcode) {
|
||||||
for c := code; !c.IsEnd(); {
|
for c := code; !c.IsEnd(); {
|
||||||
if c.Op == OpInterface {
|
if c.Op == OpInterface || c.Op == OpInterfacePtr {
|
||||||
c.Length = uint32(code.TotalLength())
|
c.Length = uint32(code.TotalLength())
|
||||||
}
|
}
|
||||||
c = c.IterNext()
|
c = c.IterNext()
|
||||||
|
|
Loading…
Reference in New Issue