Skip to content

Commit

Permalink
internal/core/export: retain top in embedded scalars
Browse files Browse the repository at this point in the history
Fixes #718

Change-Id: I9070a8621c513c7adc3d57d2ef7e650e26a308e6
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8566
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Feb 5, 2021
1 parent d9d0487 commit fdccfbc
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 6 deletions.
1 change: 0 additions & 1 deletion internal/core/export/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ func (e *conjuncts) addExpr(env *adt.Environment, x adt.Expr, isEmbed bool) {
case adt.Value: // other values.
switch v := x.(type) {
case nil:
case *adt.Top:
default:
e.values.AddConjunct(adt.MakeRootConjunct(env, x)) // GOBBLE TOP

Expand Down
59 changes: 59 additions & 0 deletions internal/core/export/testdata/embedscalar.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ sub: {
#baz: "foo"
}
}

issue718: {
#fn: {
#a + #b
#a: int
#b: int
}
#fn & {_, #a: 1, #b: 2}
}
-- out/definition --
#top: 4
sub: {
Expand All @@ -26,6 +35,18 @@ sub: {
#baz: "foo"
}
}
issue718: {
#fn & {
_
#a: 1
#b: 2
}
#fn: {
#a + #b
#a: int
#b: int
}
}
-- out/doc --
[]
[#top]
Expand All @@ -38,13 +59,20 @@ sub: {
[sub b #baz]
[sub b 0]
[sub b 1]
[issue718]
[issue718 #a]
[issue718 #b]
[issue718 #fn]
[issue718 #fn #a]
[issue718 #fn #b]
-- out/value --
== Simplified
{
sub: {
a: 3
b: [1, 2]
}
issue718: 3
}
== Raw
{
Expand All @@ -61,13 +89,24 @@ sub: {
[1, 2]
}
}
issue718: {
3
#fn: {
#a + #b
#a: int
#b: int
}
#a: 1
#b: 2
}
}
== Final
{
sub: {
a: 3
b: [1, 2]
}
issue718: 3
}
== All
{
Expand All @@ -84,6 +123,16 @@ sub: {
[1, 2]
}
}
issue718: {
3
#fn: {
#a + #b
#a: int
#b: int
}
#a: 1
#b: 2
}
}
== Eval
{
Expand All @@ -100,4 +149,14 @@ sub: {
[1, 2]
}
}
issue718: {
3
#fn: {
#a + #b
#a: int
#b: int
}
#a: 1
#b: 2
}
}
7 changes: 4 additions & 3 deletions internal/core/export/testdata/merge.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
}
-- out/definition --
#A: {
_
#a: string
}
#E: {}
#F: {}
#G: {}
#E: _
#F: _
#G: _
#B: #A & {
#E & #F
#G
Expand Down
4 changes: 2 additions & 2 deletions internal/filetypes/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fdccfbc

Please sign in to comment.