internal/core/eval: handle embedded top correctly
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>
diff --git a/cue/testdata/eval/basictypes.txtar b/cue/testdata/eval/basictypes.txtar
new file mode 100644
index 0000000..75020fd
--- /dev/null
+++ b/cue/testdata/eval/basictypes.txtar
@@ -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
+ }
+}
diff --git a/internal/core/adt/eval.go b/internal/core/adt/eval.go
index 99ca681..7386e66 100644
--- a/internal/core/adt/eval.go
+++ b/internal/core/adt/eval.go
@@ -1082,11 +1082,6 @@
// 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
diff --git a/internal/core/export/testdata/merge.txtar b/internal/core/export/testdata/merge.txtar
index 3dd2ac3..a845438 100644
--- a/internal/core/export/testdata/merge.txtar
+++ b/internal/core/export/testdata/merge.txtar
@@ -54,11 +54,12 @@
== Raw
{
#A: {
+ _
#a: string
}
- #E: {}
- #F: {}
- #G: {}
+ #E: _
+ #F: _
+ #G: _
#B: {
2
#a: string
@@ -72,11 +73,12 @@
== All
{
#A: {
+ _
#a: string
}
- #E: {}
- #F: {}
- #G: {}
+ #E: _
+ #F: _
+ #G: _
#B: {
2
#a: string
@@ -88,11 +90,12 @@
== Eval
{
#A: {
+ _
#a: string
}
- #E: {}
- #F: {}
- #G: {}
+ #E: _
+ #F: _
+ #G: _
#B: {
2
#a: string