From e3d90ebfb745e05841d1d45ecabe9b444802b2bb Mon Sep 17 00:00:00 2001 From: Artem Date: Tue, 23 Apr 2024 19:38:36 +0200 Subject: [PATCH] Fix: diff OR primitive --- go.mod | 6 +++--- go.sum | 12 ++++++------ internal/bcd/ast/ast_test.go | 4 ++-- internal/bcd/ast/miguel.go | 3 +++ internal/bcd/ast/or.go | 4 ++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 1d2bc8b6f..7e0443f2e 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/go-playground/validator/v10 v10.15.5 github.com/go-testfixtures/testfixtures/v3 v3.9.0 github.com/google/uuid v1.3.0 - github.com/grafana/pyroscope-go v1.0.3 + github.com/grafana/pyroscope-go v1.1.1 github.com/iancoleman/strcase v0.3.0 github.com/ipfs/go-cid v0.3.2 github.com/jessevdk/go-flags v1.5.0 @@ -79,7 +79,7 @@ require ( github.com/golang/protobuf v1.5.3 // indirect github.com/gomodule/redigo v2.0.0+incompatible // indirect github.com/gorilla/css v1.0.0 // indirect - github.com/grafana/pyroscope-go/godeltaprof v0.1.4 // indirect + github.com/grafana/pyroscope-go/godeltaprof v0.1.6 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect github.com/jackc/pgx/v5 v5.5.4 // indirect @@ -87,7 +87,7 @@ require ( github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/karlseguin/expect v1.0.8 // indirect - github.com/klauspost/compress v1.16.5 // indirect + github.com/klauspost/compress v1.17.3 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/magiconair/properties v1.8.7 // indirect diff --git a/go.sum b/go.sum index d4dafac1e..f1de6df33 100644 --- a/go.sum +++ b/go.sum @@ -176,10 +176,10 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= -github.com/grafana/pyroscope-go v1.0.3 h1:8WWmItzLfg4m8G+j//ElSjMeMr88Y6Lvblar6qeTyKk= -github.com/grafana/pyroscope-go v1.0.3/go.mod h1:0d7ftwSMBV/Awm7CCiYmHQEG8Y44Ma3YSjt+nWcWztY= -github.com/grafana/pyroscope-go/godeltaprof v0.1.4 h1:mDsJ3ngul7UfrHibGQpV66PbZ3q1T8glz/tK3bQKKEk= -github.com/grafana/pyroscope-go/godeltaprof v0.1.4/go.mod h1:1HSPtjU8vLG0jE9JrTdzjgFqdJ/VgN7fvxBNq3luJko= +github.com/grafana/pyroscope-go v1.1.1 h1:PQoUU9oWtO3ve/fgIiklYuGilvsm8qaGhlY4Vw6MAcQ= +github.com/grafana/pyroscope-go v1.1.1/go.mod h1:Mw26jU7jsL/KStNSGGuuVYdUq7Qghem5P8aXYXSXG88= +github.com/grafana/pyroscope-go/godeltaprof v0.1.6 h1:nEdZ8louGAplSvIJi1HVp7kWvFvdiiYg3COLlTwJiFo= +github.com/grafana/pyroscope-go/godeltaprof v0.1.6/go.mod h1:Tk376Nbldo4Cha9RgiU7ik8WKFkNpfds98aUzS8omLE= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= @@ -226,8 +226,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= -github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.3 h1:qkRjuerhUU1EmXLYGkSH6EZL+vPSxIrYjLNAK4slzwA= +github.com/klauspost/compress v1.17.3/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= diff --git a/internal/bcd/ast/ast_test.go b/internal/bcd/ast/ast_test.go index b70fe1116..956cc1808 100644 --- a/internal/bcd/ast/ast_test.go +++ b/internal/bcd/ast/ast_test.go @@ -1106,7 +1106,7 @@ func TestTypedAst_Diff(t *testing.T) { tree: `{"prim":"or","args":[{"prim":"int"},{"prim":"string"}]}`, curr: `{"prim":"Left","args":[{"int":"10"}]}`, prev: `{"prim":"Right","args":[{"string":"test"}]}`, - want: `{"prim":"or","type":"or","name":"@or_1","diff_type":"update","children":[{"prim":"string","type":"string","name":"@string_3","diff_type":"update","value":"test"}]}`, + want: `{"prim":"or","type":"or","name":"@or_1","diff_type":"update","children":[{"prim":"int","type":"int","name":"@int_2","diff_type":"update","value":"10"}]}`, }, { name: "or test", tree: `{"prim":"or","args":[{"prim":"int"},{"prim":"string"}]}`, @@ -1118,7 +1118,7 @@ func TestTypedAst_Diff(t *testing.T) { tree: `{"prim":"or","args":[{"prim":"int"},{"prim":"string"}]}`, curr: `{"prim":"Right","args":[{"string":"test"}]}`, prev: `{"prim":"Left","args":[{"int":"0"}]}`, - want: `{"prim":"or","type":"or","name":"@or_1","diff_type":"update","children":[{"prim":"int","type":"int","name":"@int_2","diff_type":"update","value":"0"}]}`, + want: `{"prim":"or","type":"or","name":"@or_1","diff_type":"update","children":[{"prim":"string","type":"string","name":"@string_3","diff_type":"update","value":"test"}]}`, }, { name: "or test", tree: `{"prim":"or","args":[{"prim":"int"},{"prim":"string"}]}`, diff --git a/internal/bcd/ast/miguel.go b/internal/bcd/ast/miguel.go index 1a13d903c..0cb1a7ccc 100644 --- a/internal/bcd/ast/miguel.go +++ b/internal/bcd/ast/miguel.go @@ -42,6 +42,9 @@ func (node *MiguelNode) print(depth int) string { if node.Value != nil { s.WriteString(fmt.Sprintf(" value=%v", node.Value)) } + if node.DiffType != "" { + s.WriteString(fmt.Sprintf(" diff_type=%v", node.DiffType)) + } s.WriteByte('\n') for i := range node.Children { s.WriteString(node.Children[i].print(depth + 1)) diff --git a/internal/bcd/ast/or.go b/internal/bcd/ast/or.go index 5a9c0604a..d83317edf 100644 --- a/internal/bcd/ast/or.go +++ b/internal/bcd/ast/or.go @@ -427,7 +427,7 @@ func (or *Or) Distinguish(x Distinguishable) (*MiguelNode, error) { case or.key == 0 && second.key == 0: default: if second.key == rightKey { - child, err := second.RightType.ToMiguel() + child, err := or.LeftType.ToMiguel() if err != nil { return nil, err } @@ -435,7 +435,7 @@ func (or *Or) Distinguish(x Distinguishable) (*MiguelNode, error) { node.setDiffType(MiguelKindUpdate) } if second.key == leftKey { - child, err := second.LeftType.ToMiguel() + child, err := or.RightType.ToMiguel() if err != nil { return nil, err }