diff --git a/cue/types.go b/cue/types.go index 7a2e6294d..e207a3879 100644 --- a/cue/types.go +++ b/cue/types.go @@ -1766,24 +1766,20 @@ func (v Value) UnifyAccept(w Value, accept Value) Value { n.AddConjunct(cv) n.AddConjunct(cw) - n.Finalize(ctx) - - n.Parent = v.v.Parent - n.Label = v.v.Label - - if err := n.Err(ctx); err != nil { - return makeValue(v.idx, n, v.parent_) - } - if err := allowed(ctx, accept.v, n); err != nil { - return newErrValue(accept, err) - } - case internal.EvalV3: n.AddOpenConjunct(ctx, v.v) n.AddOpenConjunct(ctx, w.v) - ca := adt.MakeRootConjunct(nil, accept.v) - n.AddConjunct(ca) - n.Finalize(ctx) + } + n.Finalize(ctx) + + n.Parent = v.v.Parent + n.Label = v.v.Label + + if err := n.Err(ctx); err != nil { + return makeValue(v.idx, n, v.parent_) + } + if err := allowed(ctx, accept.v, n); err != nil { + return newErrValue(accept, err) } return makeValue(v.idx, n, v.parent_) diff --git a/cue/types_test.go b/cue/types_test.go index e2a36caed..33c36fe0d 100644 --- a/cue/types_test.go +++ b/cue/types_test.go @@ -2409,8 +2409,9 @@ func TestUnifyAccept(t *testing.T) { // Issue #3829 func TestConjunctDedup(t *testing.T) { type testCase struct { - value string - want string + value string + want string + conjuncts string // only tested if not "" } testCases := []testCase{{ value: ` @@ -2423,6 +2424,16 @@ func TestConjunctDedup(t *testing.T) { f1: int f: string }`, + }, { + // Issue #3847 + value: ` + import "struct" + + #t: struct.MinFields(4) + #t: struct.MaxFields(9) + `, + want: `struct.MinFields(4) & struct.MaxFields(9)`, + conjuncts: `[struct.MinFields(4) struct.MaxFields(9)]`, }} matrix := cuetdtest.FullMatrix @@ -2446,6 +2457,12 @@ func TestConjunctDedup(t *testing.T) { } } t.Equal(fmt.Sprint(v), tc.want) + + _, args = v.Expr() + if tc.conjuncts == "" { + return + } + t.Equal(fmt.Sprint(args), tc.conjuncts) }) }) } diff --git a/encoding/openapi/testdata/embed.txtar b/encoding/openapi/testdata/embed.txtar index e4bb5942e..eb5113ff9 100644 --- a/encoding/openapi/testdata/embed.txtar +++ b/encoding/openapi/testdata/embed.txtar @@ -1,5 +1,3 @@ -#skip-v3 -#skip-v3-noshare -- in.cue -- #Foo: string diff --git a/encoding/openapi/testdata/struct.txtar b/encoding/openapi/testdata/struct.txtar index 991718e4c..5b1bbf97c 100644 --- a/encoding/openapi/testdata/struct.txtar +++ b/encoding/openapi/testdata/struct.txtar @@ -1,4 +1,4 @@ -#skip-v3-noshare +#skip-v3 -- in.cue -- import "struct"