Skip to content

Commit

Permalink
internal/core/eval: handle embedded top correctly
Browse files Browse the repository at this point in the history
Other basic types were already correctly handled,
but top slipped through the maze.

Uncovered while debugging Issue #758

Change-Id: Iee99e0a0c5e8c1a7b2faa02b484c64f0e549391f
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8707
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
  • Loading branch information
mpvl committed Feb 15, 2021
1 parent 87d43b7 commit bcd752a
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 14 deletions.
49 changes: 49 additions & 0 deletions cue/testdata/eval/basictypes.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
-- in.cue --
top: {
a: {_}
b: _
}

scalar: {
a: {string}
b: string
c: {{{number}}}
d: number
}
-- out/eval --
(struct){
top: (struct){
a: (_){ _ }
b: (_){ _ }
}
scalar: (struct){
a: (string){ string }
b: (string){ string }
c: (number){ number }
d: (number){ number }
}
}
-- out/compile --
--- in.cue
{
top: {
a: {
_
}
b: _
}
scalar: {
a: {
string
}
b: string
c: {
{
{
number
}
}
}
d: number
}
}
5 changes: 0 additions & 5 deletions internal/core/adt/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -1082,11 +1082,6 @@ func (n *nodeContext) getValidators() BaseValue {
// Src is the combined input.
v = &BasicType{K: n.kind}

if len(n.node.Structs) > 0 {
v = structSentinel

}

case 1:
v = a[0].(Value) // remove cast

Expand Down
21 changes: 12 additions & 9 deletions internal/core/export/testdata/merge.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@
== Raw
{
#A: {
_
#a: string
}
#E: {}
#F: {}
#G: {}
#E: _
#F: _
#G: _
#B: {
2
#a: string
Expand All @@ -72,11 +73,12 @@
== All
{
#A: {
_
#a: string
}
#E: {}
#F: {}
#G: {}
#E: _
#F: _
#G: _
#B: {
2
#a: string
Expand All @@ -88,11 +90,12 @@
== Eval
{
#A: {
_
#a: string
}
#E: {}
#F: {}
#G: {}
#E: _
#F: _
#G: _
#B: {
2
#a: string
Expand Down

0 comments on commit bcd752a

Please sign in to comment.