diff --git a/cmd/cue/cmd/common.go b/cmd/cue/cmd/common.go index 31c2f6453..940118252 100644 --- a/cmd/cue/cmd/common.go +++ b/cmd/cue/cmd/common.go @@ -173,9 +173,8 @@ func (b *buildPlan) instances() iterator { } default: i = &instanceIterator{ - inst: b.instance, - a: []*cue.Instance{b.instance}, - i: -1, + a: []*cue.Instance{b.instance}, + i: -1, } b.instance = nil } diff --git a/cmd/cue/cmd/testdata/script/eval_e_hidden.txt b/cmd/cue/cmd/testdata/script/eval_e_hidden.txt index 0148499f4..3f0a3d80b 100644 --- a/cmd/cue/cmd/testdata/script/eval_e_hidden.txt +++ b/cmd/cue/cmd/testdata/script/eval_e_hidden.txt @@ -7,6 +7,10 @@ stdout '34' cue eval -e _a tst.cue stdout '34' + +cue eval -H +stdout '_a: 34' + -- dep.cue -- package dep diff --git a/cmd/cue/cmd/testdata/script/hidden.txt b/cmd/cue/cmd/testdata/script/hidden.txt new file mode 100644 index 000000000..32ecf7a8d --- /dev/null +++ b/cmd/cue/cmd/testdata/script/hidden.txt @@ -0,0 +1,46 @@ +cue eval pkg.cue -H +cmp stdout expect-stdout + +cue eval -H +cmp stdout expect-stdout + +cue eval file.cue -H +cmp stdout expect-stdout + +-- pkg.cue -- +package pkg + +_top: 1 + +a: _h0: int + +#foo: { + _h1: string +} + +{ + _h2: string +} + +-- file.cue -- +_top: 1 + +a: _h0: int + +#foo: { + _h1: string +} + +{ + _h2: string +} + +-- expect-stdout -- +_top: 1 +a: { + _h0: int +} +_h2: string +#foo: { + _h1: string +} diff --git a/cue/types.go b/cue/types.go index 636fe5222..3502e4aed 100644 --- a/cue/types.go +++ b/cue/types.go @@ -1815,7 +1815,7 @@ func (v Value) Unify(w Value) Value { if v.v == nil { return w } - if w.v == nil { + if w.v == nil || w.v == v.v { return v } diff --git a/internal/core/adt/feature.go b/internal/core/adt/feature.go index 2df36569e..a09931408 100644 --- a/internal/core/adt/feature.go +++ b/internal/core/adt/feature.go @@ -107,7 +107,7 @@ func (f Feature) PkgID(index StringIndexer) string { } s := index.IndexToString(f.safeIndex()) if p := strings.IndexByte(s, '\x00'); p >= 0 { - return s[p+1:] + s = s[p+1:] } return s }