...

Text file src/cuelang.org/go/cue/testdata/eval/incomplete.txtar

Documentation: cuelang.org/go/cue/testdata/eval

     1-- in.cue --
     2s: string
     3
     4e1:  s + s
     5e2:  >"bar" & s // okay
     6e3:  >s & "foo" // not okay
     7e3b: >s
     8
     9e4: >e1 & s
    10e5: <e5 & s
    11
    12E: {
    13	a: c - b
    14	b: c - a
    15	c: a+b & >=5
    16}
    17
    18a:    int
    19okay: (>10 & <a) + 3
    20
    21issue1837: {
    22	// x is properly recognized as erroneous and the "message" field is added
    23	// with the value "a", instead of as a cycle error.
    24	p1: {
    25		context: {}
    26		x: context.b // incomplete error
    27		if x == _|_ {
    28			message: "a"
    29		}
    30	}
    31	p2: {
    32		if x == _|_ {
    33			message: "a"
    34		}
    35		x: context.b // incomplete error
    36		context: {}
    37	}
    38	p3: {
    39		if x == _|_ {
    40			message: "a"
    41		}
    42		context: {}
    43		x: context.b // incomplete error
    44	}
    45}
    46-- out/eval/stats --
    47Leaks:  0
    48Freed:  32
    49Reused: 26
    50Allocs: 6
    51Retain: 96
    52
    53Unifications: 32
    54Conjuncts:    172
    55Disjuncts:    45
    56-- out/evalalpha --
    57(struct){
    58  s: (string){ string }
    59  e1: (_|_){
    60    // [incomplete] e1: non-concrete value string in operand to +:
    61    //     ./in.cue:3:6
    62    //     ./in.cue:1:4
    63  }
    64  e2: (string){ >"bar" }
    65  e3: (_|_){
    66    // [incomplete] e3: non-concrete value s for bound >:
    67    //     ./in.cue:5:7
    68  }
    69  e3b: (_|_){
    70    // [incomplete] e3b: non-concrete value s for bound >:
    71    //     ./in.cue:6:7
    72  }
    73  e4: (_|_){
    74    // [incomplete] e1: non-concrete value string in operand to +:
    75    //     ./in.cue:3:6
    76    //     ./in.cue:1:4
    77  }
    78  e5: (_|_){
    79    // [incomplete] e5: non-concrete value e5 for bound <:
    80    //     ./in.cue:9:6
    81  }
    82  E: (struct){
    83    a: (_|_){
    84      // [incomplete] E.b: non-concrete value >=5 in operand to -:
    85      //     ./in.cue:13:5
    86      //     ./in.cue:14:11
    87      // E.c: non-concrete value _ in operand to +:
    88      //     ./in.cue:14:5
    89    }
    90    b: (_|_){
    91      // [incomplete] E.b: non-concrete value >=5 in operand to -:
    92      //     ./in.cue:13:5
    93      //     ./in.cue:14:11
    94    }
    95    c: (_|_){
    96      // [incomplete] E.b: non-concrete value >=5 in operand to -:
    97      //     ./in.cue:13:5
    98      //     ./in.cue:14:11
    99      // E.c: non-concrete value _ in operand to +:
   100      //     ./in.cue:14:5
   101    }
   102  }
   103  a: (int){ int }
   104  okay: (_|_){
   105    // [incomplete] non-concrete value a for bound <:
   106    //     ./in.cue:18:15
   107  }
   108  issue1837: (struct){
   109    p1: (struct){
   110      context: (struct){
   111      }
   112      x: (_|_){
   113        // [incomplete] issue1837.p1.x: undefined field: b:
   114        //     ./in.cue:25:14
   115      }
   116      message: (string){ "a" }
   117    }
   118    p2: (struct){
   119      message: (string){ "a" }
   120      x: (_|_){
   121        // [incomplete] issue1837.p2.x: undefined field: b:
   122        //     ./in.cue:34:14
   123      }
   124      context: (struct){
   125      }
   126    }
   127    p3: (struct){
   128      message: (string){ "a" }
   129      context: (struct){
   130      }
   131      x: (_|_){
   132        // [incomplete] issue1837.p3.x: undefined field: b:
   133        //     ./in.cue:42:14
   134      }
   135    }
   136  }
   137}
   138-- diff/-out/evalalpha<==>+out/eval --
   139diff old new
   140--- old
   141+++ new
   142@@ -20,22 +20,28 @@
   143     //     ./in.cue:1:4
   144   }
   145   e5: (_|_){
   146-    // [cycle] cycle error
   147+    // [incomplete] e5: non-concrete value e5 for bound <:
   148+    //     ./in.cue:9:6
   149   }
   150   E: (struct){
   151     a: (_|_){
   152-      // [cycle] cycle error:
   153-      //     ./in.cue:12:5
   154+      // [incomplete] E.b: non-concrete value >=5 in operand to -:
   155+      //     ./in.cue:13:5
   156+      //     ./in.cue:14:11
   157+      // E.c: non-concrete value _ in operand to +:
   158+      //     ./in.cue:14:5
   159     }
   160     b: (_|_){
   161-      // [cycle] cycle error:
   162-      //     ./in.cue:13:5
   163+      // [incomplete] E.b: non-concrete value >=5 in operand to -:
   164+      //     ./in.cue:13:5
   165+      //     ./in.cue:14:11
   166     }
   167     c: (_|_){
   168-      // [cycle] cycle error:
   169-      //     ./in.cue:12:5
   170-      // cycle error:
   171-      //     ./in.cue:13:5
   172+      // [incomplete] E.b: non-concrete value >=5 in operand to -:
   173+      //     ./in.cue:13:5
   174+      //     ./in.cue:14:11
   175+      // E.c: non-concrete value _ in operand to +:
   176+      //     ./in.cue:14:5
   177     }
   178   }
   179   a: (int){ int }
   180-- diff/explanation --
   181Improved error messages.
   182-- out/eval --
   183(struct){
   184  s: (string){ string }
   185  e1: (_|_){
   186    // [incomplete] e1: non-concrete value string in operand to +:
   187    //     ./in.cue:3:6
   188    //     ./in.cue:1:4
   189  }
   190  e2: (string){ >"bar" }
   191  e3: (_|_){
   192    // [incomplete] e3: non-concrete value s for bound >:
   193    //     ./in.cue:5:7
   194  }
   195  e3b: (_|_){
   196    // [incomplete] e3b: non-concrete value s for bound >:
   197    //     ./in.cue:6:7
   198  }
   199  e4: (_|_){
   200    // [incomplete] e1: non-concrete value string in operand to +:
   201    //     ./in.cue:3:6
   202    //     ./in.cue:1:4
   203  }
   204  e5: (_|_){
   205    // [cycle] cycle error
   206  }
   207  E: (struct){
   208    a: (_|_){
   209      // [cycle] cycle error:
   210      //     ./in.cue:12:5
   211    }
   212    b: (_|_){
   213      // [cycle] cycle error:
   214      //     ./in.cue:13:5
   215    }
   216    c: (_|_){
   217      // [cycle] cycle error:
   218      //     ./in.cue:12:5
   219      // cycle error:
   220      //     ./in.cue:13:5
   221    }
   222  }
   223  a: (int){ int }
   224  okay: (_|_){
   225    // [incomplete] non-concrete value a for bound <:
   226    //     ./in.cue:18:15
   227  }
   228  issue1837: (struct){
   229    p1: (struct){
   230      context: (struct){
   231      }
   232      x: (_|_){
   233        // [incomplete] issue1837.p1.x: undefined field: b:
   234        //     ./in.cue:25:14
   235      }
   236      message: (string){ "a" }
   237    }
   238    p2: (struct){
   239      message: (string){ "a" }
   240      x: (_|_){
   241        // [incomplete] issue1837.p2.x: undefined field: b:
   242        //     ./in.cue:34:14
   243      }
   244      context: (struct){
   245      }
   246    }
   247    p3: (struct){
   248      message: (string){ "a" }
   249      context: (struct){
   250      }
   251      x: (_|_){
   252        // [incomplete] issue1837.p3.x: undefined field: b:
   253        //     ./in.cue:42:14
   254      }
   255    }
   256  }
   257}
   258-- out/compile --
   259--- in.cue
   260{
   261  s: string
   262  e1: (〈0;s〉 + 〈0;s〉)
   263  e2: (>"bar" & 〈0;s〉)
   264  e3: (>〈0;s〉 & "foo")
   265  e3b: >〈0;s〉
   266  e4: (>〈0;e1〉 & 〈0;s〉)
   267  e5: (<〈0;e5〉 & 〈0;s〉)
   268  E: {
   269    a: (〈0;c〉 - 〈0;b〉)
   270    b: (〈0;c〉 - 〈0;a〉)
   271    c: ((〈0;a〉 + 〈0;b〉) & >=5)
   272  }
   273  a: int
   274  okay: ((>10 & <〈0;a〉) + 3)
   275  issue1837: {
   276    p1: {
   277      context: {}
   278      x: 〈0;context〉.b
   279      if (〈0;x〉 == _|_(explicit error (_|_ literal) in source)) {
   280        message: "a"
   281      }
   282    }
   283    p2: {
   284      if (〈0;x〉 == _|_(explicit error (_|_ literal) in source)) {
   285        message: "a"
   286      }
   287      x: 〈0;context〉.b
   288      context: {}
   289    }
   290    p3: {
   291      if (〈0;x〉 == _|_(explicit error (_|_ literal) in source)) {
   292        message: "a"
   293      }
   294      context: {}
   295      x: 〈0;context〉.b
   296    }
   297  }
   298}

View as plain text