Issue #560

-- cue.mod/module.cue --
module: "mod.test"
language: version: "v0.9.0"
-- in.cue --
import "strings"

dynamic: {
	for _, s in ["foo"] {
		(s):       1
		"\(s)bar": 2
	}
}

ignoreOptional: {
	#x: {
		a?: string
		b?: string
		c:  string
	}

	y: {
		for k,v in #x {
			(k): "exists"
		}
	}
}

missingRequiredError:  {
	// Issue #2369
	#x: {
		a!: string
		b?: string
		c:  string
	}

	y: {
		for k,v in #x {
			(k): "exists"
		}
	}
}

issue560: {
	#User: {
		tags_str: string
		tags_map: {
			for k, v in strings.Split(tags_str, " ") {
				"\(v)": string
			}
			"{a}": string
		}
	}

	user: {
		#User
		tags_str: "b {c}"
	}
}
-- out/eval/stats --
Leaks:  1
Freed:  29
Reused: 24
Allocs: 6
Retain: 1

Unifications: 30
Conjuncts:    38
Disjuncts:    30
-- out/evalalpha --
(struct){
  dynamic: (struct){
    foo: (int){ 1 }
    foobar: (int){ 2 }
  }
  ignoreOptional: (struct){
    #x: (#struct){
      a?: (string){ string }
      b?: (string){ string }
      c: (string){ string }
    }
    y: (struct){
      c: (string){ "exists" }
    }
  }
  missingRequiredError: (struct){
    #x: (#struct){
      a!: (string){ string }
      b?: (string){ string }
      c: (string){ string }
    }
    y: (_|_){
      // [incomplete] missingRequiredError.y: missing required field in for comprehension: a:
      //     ./in.cue:33:3
      //     ./in.cue:27:3
      //     ./in.cue:33:14
      // missingRequiredError.y: key value of dynamic field must be concrete, found _|_(missingRequiredError.y: missing required field in for comprehension: a):
      //     ./in.cue:34:5
    }
  }
  issue560: (struct){
    #User: (#struct){
      tags_str: (string){ string }
      tags_map: (_|_){
        // [incomplete] issue560.#User.tags_map: error in call to strings.Split: non-concrete value string:
        //     ./in.cue:43:16
        //     ./in.cue:41:13
        "{a}": (string){ string }
      }
    }
    user: (#struct){
      tags_str: (string){ "b {c}" }
      tags_map: (#struct){
        "{a}": (string){ string }
        b: (string){ string }
        "{c}": (string){ string }
      }
    }
  }
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -24,6 +24,8 @@
       //     ./in.cue:33:3
       //     ./in.cue:27:3
       //     ./in.cue:33:14
+      // missingRequiredError.y: key value of dynamic field must be concrete, found _|_(missingRequiredError.y: missing required field in for comprehension: a):
+      //     ./in.cue:34:5
     }
   }
   issue560: (struct){
-- diff/todo/p2 --
Near-duplicate message
-- out/eval --
(struct){
  dynamic: (struct){
    foo: (int){ 1 }
    foobar: (int){ 2 }
  }
  ignoreOptional: (struct){
    #x: (#struct){
      a?: (string){ string }
      b?: (string){ string }
      c: (string){ string }
    }
    y: (struct){
      c: (string){ "exists" }
    }
  }
  missingRequiredError: (struct){
    #x: (#struct){
      a!: (string){ string }
      b?: (string){ string }
      c: (string){ string }
    }
    y: (_|_){
      // [incomplete] missingRequiredError.y: missing required field in for comprehension: a:
      //     ./in.cue:33:3
      //     ./in.cue:27:3
      //     ./in.cue:33:14
    }
  }
  issue560: (struct){
    #User: (#struct){
      tags_str: (string){ string }
      tags_map: (_|_){
        // [incomplete] issue560.#User.tags_map: error in call to strings.Split: non-concrete value string:
        //     ./in.cue:43:16
        //     ./in.cue:41:13
        "{a}": (string){ string }
      }
    }
    user: (#struct){
      tags_str: (string){ "b {c}" }
      tags_map: (#struct){
        "{a}": (string){ string }
        b: (string){ string }
        "{c}": (string){ string }
      }
    }
  }
}
-- out/compile --
--- in.cue
{
  dynamic: {
    for _, s in [
      "foo",
    ] {
      〈1;s〉: 1
      "\(〈1;s〉)bar": 2
    }
  }
  ignoreOptional: {
    #x: {
      a?: string
      b?: string
      c: string
    }
    y: {
      for k, v in 〈1;#x〉 {
        〈1;k〉: "exists"
      }
    }
  }
  missingRequiredError: {
    #x: {
      a!: string
      b?: string
      c: string
    }
    y: {
      for k, v in 〈1;#x〉 {
        〈1;k〉: "exists"
      }
    }
  }
  issue560: {
    #User: {
      tags_str: string
      tags_map: {
        for k, v in 〈import;strings〉.Split(〈1;tags_str〉, " ") {
          "\(〈1;v〉)": string
        }
        "{a}": string
      }
    }
    user: {
      〈1;#User〉
      tags_str: "b {c}"
    }
  }
}
