this repo has no description
0
fork

Configure Feed

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

cue/cmd/cue: fix regression for -H flag

Instance iterator accidentally would include instance twice
in some cases, which caused it to be unified into a new
anonoymous package for which hidden fields would not
be shown.

Also adds an optimization in Unify to return one of
the arguments if they are identical, instead of unifying.

The setting the variable instead of returning makes using
a debugger easier.

Change-Id: I311c0d2dcb50d277a47eaaae352e5fb467935eba
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9844
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>

+54 -5
+2 -3
cmd/cue/cmd/common.go
··· 173 173 } 174 174 default: 175 175 i = &instanceIterator{ 176 - inst: b.instance, 177 - a: []*cue.Instance{b.instance}, 178 - i: -1, 176 + a: []*cue.Instance{b.instance}, 177 + i: -1, 179 178 } 180 179 b.instance = nil 181 180 }
+4
cmd/cue/cmd/testdata/script/eval_e_hidden.txt
··· 7 7 8 8 cue eval -e _a tst.cue 9 9 stdout '34' 10 + 11 + cue eval -H 12 + stdout '_a: 34' 13 + 10 14 -- dep.cue -- 11 15 package dep 12 16
+46
cmd/cue/cmd/testdata/script/hidden.txt
··· 1 + cue eval pkg.cue -H 2 + cmp stdout expect-stdout 3 + 4 + cue eval -H 5 + cmp stdout expect-stdout 6 + 7 + cue eval file.cue -H 8 + cmp stdout expect-stdout 9 + 10 + -- pkg.cue -- 11 + package pkg 12 + 13 + _top: 1 14 + 15 + a: _h0: int 16 + 17 + #foo: { 18 + _h1: string 19 + } 20 + 21 + { 22 + _h2: string 23 + } 24 + 25 + -- file.cue -- 26 + _top: 1 27 + 28 + a: _h0: int 29 + 30 + #foo: { 31 + _h1: string 32 + } 33 + 34 + { 35 + _h2: string 36 + } 37 + 38 + -- expect-stdout -- 39 + _top: 1 40 + a: { 41 + _h0: int 42 + } 43 + _h2: string 44 + #foo: { 45 + _h1: string 46 + }
+1 -1
cue/types.go
··· 1815 1815 if v.v == nil { 1816 1816 return w 1817 1817 } 1818 - if w.v == nil { 1818 + if w.v == nil || w.v == v.v { 1819 1819 return v 1820 1820 } 1821 1821
+1 -1
internal/core/adt/feature.go
··· 107 107 } 108 108 s := index.IndexToString(f.safeIndex()) 109 109 if p := strings.IndexByte(s, '\x00'); p >= 0 { 110 - return s[p+1:] 110 + s = s[p+1:] 111 111 } 112 112 return s 113 113 }