Closed zhongxinghong closed 2 weeks ago
The https://github.com/bytedance/sonic/pull/630 lost self.parser.p++ for empty object in (*traverser).decodeObject(). The TwitterJSON doesn't contain pattern like {..., "k": {}, ...} so this problem was not detected by unit tests.
self.parser.p++
{..., "k": {}, ...}
Test case: {"v0": 0, "m0": {}, "v1": 1, "a0": [], "v2": 2} Output:
{"v0": 0, "m0": {}, "v1": 1, "a0": [], "v2": 2}
=== RUN TestVisitor_NodeDiff/issue_case02 visitor_test.go:243: Error Trace: /Users/bytedance/go/src/github.com/bytedance/sonic/ast/visitor_test.go:243 /Users/bytedance/go/src/github.com/bytedance/sonic/ast/visitor.go:304 /Users/bytedance/go/src/github.com/bytedance/sonic/ast/visitor.go:167 /Users/bytedance/go/src/github.com/bytedance/sonic/ast/visitor.go:132 /Users/bytedance/go/src/github.com/bytedance/sonic/ast/visitor_test.go:318 /Users/bytedance/go/src/github.com/bytedance/sonic/ast/visitor_test.go:342 Error: Not equal: expected: []string{"a0", "m0", "v0", "v1", "v2"} actual : []string{"m0", "v0"} Diff: --- Expected +++ Actual @@ -1,7 +1,4 @@ -([]string) (len=5) { - (string) (len=2) "a0", +([]string) (len=2) { (string) (len=2) "m0", - (string) (len=2) "v0", - (string) (len=2) "v1", - (string) (len=2) "v2" + (string) (len=2) "v0" } Test: TestVisitor_NodeDiff/issue_case02
The https://github.com/bytedance/sonic/pull/630 lost
self.parser.p++
for empty object in (*traverser).decodeObject(). The TwitterJSON doesn't contain pattern like{..., "k": {}, ...}
so this problem was not detected by unit tests.Test case:
{"v0": 0, "m0": {}, "v1": 1, "a0": [], "v2": 2}
Output: