this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: fix let closedness issue with API use

Code did not handle lets yet. Cross checked that other places
where IsHidden is used, IsLet is used as well if applicable.

Fixes #2325

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I774560818559143d6a02f8a3f33dff8c97485f94
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/552317
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>

+23 -6
+18 -6
cue/types_test.go
··· 2109 2109 } 2110 2110 2111 2111 func TestUnify(t *testing.T) { 2112 - a := []string{"a"} 2113 - b := []string{"b"} 2112 + a := "a" 2113 + b := "b" 2114 2114 testCases := []struct { 2115 2115 value string 2116 - pathA []string 2117 - pathB []string 2116 + pathA string 2117 + pathB string 2118 2118 want string 2119 2119 }{{ 2120 2120 value: `4`, ··· 2144 2144 pathA: a, 2145 2145 pathB: b, 2146 2146 want: `{"a":"foo"}`, 2147 + }, { 2148 + // Issue #2325: let should not result in a closedness error. 2149 + value: `#T: { 2150 + ... 2151 + } 2152 + b: { 2153 + let foobar = {} 2154 + _fb: foobar 2155 + }`, 2156 + pathA: "#T", 2157 + pathB: b, 2158 + want: `{}`, 2147 2159 }} 2148 2160 for _, tc := range testCases { 2149 2161 t.Run(tc.value, func(t *testing.T) { 2150 2162 v := getInstance(t, tc.value).Value() 2151 - x := v.Lookup(tc.pathA...) 2152 - y := v.Lookup(tc.pathB...) 2163 + x := v.LookupPath(ParsePath(tc.pathA)) 2164 + y := v.LookupPath(ParsePath(tc.pathB)) 2153 2165 b, err := x.Unify(y).MarshalJSON() 2154 2166 if err != nil { 2155 2167 t.Fatal(err)
+5
internal/core/adt/composite.go
··· 772 772 773 773 // TODO: return error instead of boolean? (or at least have version that does.) 774 774 func (v *Vertex) Accept(ctx *OpContext, f Feature) bool { 775 + // TODO(v0.6): move f.IsHidden from below to here. 776 + if f.IsLet() { 777 + return true 778 + } 779 + 775 780 if x, ok := v.BaseValue.(*Disjunction); ok { 776 781 for _, v := range x.Values { 777 782 if x, ok := v.(*Vertex); ok && x.Accept(ctx, f) {