cuelang.org/go@v0.13.0/cue/testdata/resolve/012_bound_conversions.txtar (about)

     1  #name: bound conversions
     2  #evalPartial
     3  -- in.cue --
     4  r0: int & >0.1 & <=1.9
     5  r1: int & >0.1 & <1.9
     6  r2: int & >=0.1 & <1.9
     7  r3: int & >=-1.9 & <=-0.1
     8  r4: int & >-1.9 & <=-0.1
     9  
    10  r5: >=1.1 & <=1.1
    11  r6: r5 & 1.1
    12  
    13  c1: (1.2 & >1.3) & <2
    14  c2: 1.2 & (>1.3 & <2)
    15  
    16  c3: 1.2 & (>=1 & <2)
    17  c4: 1.2 & (>=1 & <2 & int)
    18  -- out/def --
    19  r0: 1
    20  r1: 1
    21  r2: 1
    22  r3: -1
    23  r4: -1
    24  r5: 1.1
    25  r6: 1.1
    26  c1: _|_ // invalid value 1.2 (out of bound >1.3)
    27  c2: _|_ // invalid value 1.2 (out of bound >1.3)
    28  c3: 1.2
    29  c4: _|_ // conflicting values 1.2 and ((>=1 & <2) & int) (mismatched types float and int)
    30  -- out/legacy-debug --
    31  <0>{r0: 1, r1: 1, r2: 1, r3: -1, r4: -1, r5: 1.1, r6: 1.1, c1: _|_((>1.3 & 1.2):invalid value 1.2 (out of bound >1.3)), c2: _|_((>1.3 & 1.2):invalid value 1.2 (out of bound >1.3)), c3: 1.2, c4: _|_((1.2 & ((>=1 & <2) & int)):conflicting values 1.2 and ((>=1 & <2) & int) (mismatched types float and int))}
    32  -- out/compile --
    33  --- in.cue
    34  {
    35    r0: ((int & >0.1) & <=1.9)
    36    r1: ((int & >0.1) & <1.9)
    37    r2: ((int & >=0.1) & <1.9)
    38    r3: ((int & >=-1.9) & <=-0.1)
    39    r4: ((int & >-1.9) & <=-0.1)
    40    r5: (>=1.1 & <=1.1)
    41    r6: (〈0;r5〉 & 1.1)
    42    c1: ((1.2 & >1.3) & <2)
    43    c2: (1.2 & (>1.3 & <2))
    44    c3: (1.2 & (>=1 & <2))
    45    c4: (1.2 & ((>=1 & <2) & int))
    46  }
    47  -- out/eval/stats --
    48  Leaks:  0
    49  Freed:  12
    50  Reused: 10
    51  Allocs: 2
    52  Retain: 0
    53  
    54  Unifications: 12
    55  Conjuncts:    35
    56  Disjuncts:    12
    57  -- out/evalalpha --
    58  Errors:
    59  c4: conflicting values 1.2 and int (mismatched types float and int):
    60      ./in.cue:14:5
    61      ./in.cue:14:23
    62  c1: invalid value 1.2 (out of bound >1.3):
    63      ./in.cue:10:12
    64      ./in.cue:10:6
    65  c2: invalid value 1.2 (out of bound >1.3):
    66      ./in.cue:11:12
    67      ./in.cue:11:5
    68  
    69  Result:
    70  (_|_){
    71    // [eval]
    72    r0: (int){ 1 }
    73    r1: (int){ 1 }
    74    r2: (int){ 1 }
    75    r3: (int){ -1 }
    76    r4: (int){ -1 }
    77    r5: (number){ 1.1 }
    78    r6: (float){ 1.1 }
    79    c1: (_|_){
    80      // [eval] c1: invalid value 1.2 (out of bound >1.3):
    81      //     ./in.cue:10:12
    82      //     ./in.cue:10:6
    83    }
    84    c2: (_|_){
    85      // [eval] c2: invalid value 1.2 (out of bound >1.3):
    86      //     ./in.cue:11:12
    87      //     ./in.cue:11:5
    88    }
    89    c3: (float){ 1.2 }
    90    c4: (_|_){
    91      // [eval] c4: conflicting values 1.2 and int (mismatched types float and int):
    92      //     ./in.cue:14:5
    93      //     ./in.cue:14:23
    94    }
    95  }
    96  -- diff/-out/evalalpha<==>+out/eval --
    97  diff old new
    98  --- old
    99  +++ new
   100  @@ -18,7 +18,7 @@
   101     r3: (int){ -1 }
   102     r4: (int){ -1 }
   103     r5: (number){ 1.1 }
   104  -  r6: (number){ 1.1 }
   105  +  r6: (float){ 1.1 }
   106     c1: (_|_){
   107       // [eval] c1: invalid value 1.2 (out of bound >1.3):
   108       //     ./in.cue:10:12
   109  -- diff/todo/p3 --
   110  Seems like a correct fix, but investigate.
   111  This is independent from the fact that we probably
   112  want to relax the type of float literals to number.
   113  -- out/eval --
   114  Errors:
   115  c4: conflicting values 1.2 and int (mismatched types float and int):
   116      ./in.cue:14:5
   117      ./in.cue:14:23
   118  c1: invalid value 1.2 (out of bound >1.3):
   119      ./in.cue:10:12
   120      ./in.cue:10:6
   121  c2: invalid value 1.2 (out of bound >1.3):
   122      ./in.cue:11:12
   123      ./in.cue:11:5
   124  
   125  Result:
   126  (_|_){
   127    // [eval]
   128    r0: (int){ 1 }
   129    r1: (int){ 1 }
   130    r2: (int){ 1 }
   131    r3: (int){ -1 }
   132    r4: (int){ -1 }
   133    r5: (number){ 1.1 }
   134    r6: (number){ 1.1 }
   135    c1: (_|_){
   136      // [eval] c1: invalid value 1.2 (out of bound >1.3):
   137      //     ./in.cue:10:12
   138      //     ./in.cue:10:6
   139    }
   140    c2: (_|_){
   141      // [eval] c2: invalid value 1.2 (out of bound >1.3):
   142      //     ./in.cue:11:12
   143      //     ./in.cue:11:5
   144    }
   145    c3: (float){ 1.2 }
   146    c4: (_|_){
   147      // [eval] c4: conflicting values 1.2 and int (mismatched types float and int):
   148      //     ./in.cue:14:5
   149      //     ./in.cue:14:23
   150    }
   151  }