internal/core/validate: more cases to ignore concreteness

Change-Id: I6a7c14cd96841c311945ebcaf25ac369081a2917
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6705
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/internal/core/validate/validate.go b/internal/core/validate/validate.go
index c0a5479..f1da4e8 100644
--- a/internal/core/validate/validate.go
+++ b/internal/core/validate/validate.go
@@ -50,6 +50,10 @@
 	inDefinition int
 }
 
+func (v *validator) checkConcrete() bool {
+	return v.Concrete && v.inDefinition == 0
+}
+
 func (v *validator) add(b *adt.Bottom) {
 	if !v.AllErrors {
 		v.err = adt.CombineErrors(nil, v.err, b)
@@ -66,12 +70,12 @@
 	if b, _ := x.Value.(*adt.Bottom); b != nil {
 		switch b.Code {
 		case adt.CycleError:
-			if v.Concrete || v.DisallowCycles {
+			if v.checkConcrete() || v.DisallowCycles {
 				v.add(b)
 			}
 
 		case adt.IncompleteError, adt.NotExistError:
-			if v.Concrete {
+			if v.checkConcrete() {
 				v.add(b)
 			}
 
@@ -82,7 +86,7 @@
 			return
 		}
 
-	} else if v.Concrete && v.inDefinition == 0 {
+	} else if v.checkConcrete() {
 		x := x.Default()
 		if !adt.IsConcrete(x) {
 			v.add(&adt.Bottom{
diff --git a/internal/core/validate/validate_test.go b/internal/core/validate/validate_test.go
index 3d0e0df..a47afbd 100644
--- a/internal/core/validate/validate_test.go
+++ b/internal/core/validate/validate_test.go
@@ -149,6 +149,16 @@
 		in: `
 		x: *1 | 2
 		`,
+	}, {
+		desc: "allow non-concrete in definitions in concrete mode",
+		cfg:  &Config{Concrete: true},
+		in: `
+		x: 2
+		#d: {
+			b: int
+			c: b + b
+		}
+		`,
 	}}
 
 	r := runtime.New()