#name: arithmetic
#evalPartial
-- in.cue --
i1: 1 & int
i2: 2 & int

sum:     -1 + +2     // 1
div1:    2.0 / 3 * 6 // 4
div2:    2 / 3 * 6   // 4
div3:    1.00 / 1.00
divZero: 1.0 / 0
div00:   0 / 0
b:       1 != 4
add:     div1 + 1.0

idiv00: 0 div 0
imod00: 0 mod 0
iquo00: 0 quo 0
irem00: 0 rem 0

v1: 1.0T / 2.0
v2: 2.0 == 2
v3: 2.0 / 3.0
v5: i1 div i2

e0: 2 + "a"
// these are now all alloweed
// e1: 2.0 / i1
// e2: i1 / 2.0
// e3: 3.0 % i2
// e4: i1 % 2.0
e5: 1.0 div 2
e6: 2 rem 2.0
e7: 2 quo 2.0
e8: 1.0 mod 1
-- out/def --
i1:      1
i2:      2
sum:     1
div1:    4.00000000000000000000000
div2:    4.00000000000000000000000
div3:    1.
divZero: _|_ // division by zero
div00:   _|_ // division undefined
b:       true
add:     5.00000000000000000000000
idiv00:  _|_ // division by zero
imod00:  _|_ // division by zero
iquo00:  _|_ // division by zero
irem00:  _|_ // division by zero
v1:      5.0000000000e+11
v2:      true
v3:      0.666666666666666666666667
v5:      0
e0:      _|_ // invalid operation 2 + "a" (mismatched types int and string)
// these are now all alloweed
// e1: 2.0 / i1
// e2: i1 / 2.0
// e3: 3.0 % i2
// e4: i1 % 2.0
e5: _|_ // invalid operation 1.0 div 2 (mismatched types float and int)
e6: _|_ // invalid operation 2 rem 2.0 (mismatched types int and float)
e7: _|_ // invalid operation 2 quo 2.0 (mismatched types int and float)
e8: _|_ // invalid operation 1.0 mod 1 (mismatched types float and int)
-- out/legacy-debug --
<0>{i1: 1, i2: 2, sum: 1, div1: 4.00000000000000000000000, div2: 4.00000000000000000000000, div3: 1., divZero: _|_((1.0 / 0):division by zero), div00: _|_((0 / 0):division undefined), b: true, add: 5.00000000000000000000000, idiv00: _|_((0 div 0):division by zero), imod00: _|_((0 mod 0):division by zero), iquo00: _|_((0 quo 0):division by zero), irem00: _|_((0 rem 0):division by zero), v1: 5.0000000000e+11, v2: true, v3: 0.666666666666666666666667, v5: 0, e0: _|_((2 + "a"):invalid operation 2 + "a" (mismatched types int and string)), e5: _|_((1.0 div 2):invalid operation 1.0 div 2 (mismatched types float and int)), e6: _|_((2 rem 2.0):invalid operation 2 rem 2.0 (mismatched types int and float)), e7: _|_((2 quo 2.0):invalid operation 2 quo 2.0 (mismatched types int and float)), e8: _|_((1.0 mod 1):invalid operation 1.0 mod 1 (mismatched types float and int))}
-- out/compile --
--- in.cue
{
  i1: (1 & int)
  i2: (2 & int)
  sum: (-1 + +2)
  div1: ((2.0 / 3) * 6)
  div2: ((2 / 3) * 6)
  div3: (1.00 / 1.00)
  divZero: (1.0 / 0)
  div00: (0 / 0)
  b: (1 != 4)
  add: (〈0;div1〉 + 1.0)
  idiv00: (0 div 0)
  imod00: (0 mod 0)
  iquo00: (0 quo 0)
  irem00: (0 rem 0)
  v1: (1000000000000 / 2.0)
  v2: (2.0 == 2)
  v3: (2.0 / 3.0)
  v5: (〈0;i1〉 div 〈0;i2〉)
  e0: (2 + "a")
  e5: (1.0 div 2)
  e6: (2 rem 2.0)
  e7: (2 quo 2.0)
  e8: (1.0 mod 1)
}
-- out/eval/stats --
Leaks:  0
Freed:  24
Reused: 22
Allocs: 2
Retain: 0

Unifications: 24
Conjuncts:    26
Disjuncts:    24
-- out/eval --
Errors:
divZero: failed arithmetic: division by zero:
    ./in.cue:8:10
div00: failed arithmetic: division undefined:
    ./in.cue:9:10
idiv00: division by zero:
    ./in.cue:13:9
imod00: division by zero:
    ./in.cue:14:9
iquo00: division by zero:
    ./in.cue:15:9
irem00: division by zero:
    ./in.cue:16:9
e0: invalid operands 2 and "a" to '+' (type int and string):
    ./in.cue:23:5
    ./in.cue:23:9
e5: invalid operands 1.0 and 2 to 'div' (type float and int):
    ./in.cue:29:5
    ./in.cue:29:13
e6: invalid operands 2 and 2.0 to 'rem' (type int and float):
    ./in.cue:30:5
    ./in.cue:30:11
e7: invalid operands 2 and 2.0 to 'quo' (type int and float):
    ./in.cue:31:5
    ./in.cue:31:11
e8: invalid operands 1.0 and 1 to 'mod' (type float and int):
    ./in.cue:32:5
    ./in.cue:32:13

Result:
(_|_){
  // [eval]
  i1: (int){ 1 }
  i2: (int){ 2 }
  sum: (int){ 1 }
  div1: (float){ 4.000000000000000000000000000000000 }
  div2: (float){ 4.000000000000000000000000000000000 }
  div3: (float){ 1.0 }
  divZero: (_|_){
    // [eval] divZero: failed arithmetic: division by zero:
    //     ./in.cue:8:10
  }
  div00: (_|_){
    // [eval] div00: failed arithmetic: division undefined:
    //     ./in.cue:9:10
  }
  b: (bool){ true }
  add: (float){ 5.000000000000000000000000000000000 }
  idiv00: (_|_){
    // [eval] idiv00: division by zero:
    //     ./in.cue:13:9
  }
  imod00: (_|_){
    // [eval] imod00: division by zero:
    //     ./in.cue:14:9
  }
  iquo00: (_|_){
    // [eval] iquo00: division by zero:
    //     ./in.cue:15:9
  }
  irem00: (_|_){
    // [eval] irem00: division by zero:
    //     ./in.cue:16:9
  }
  v1: (float){ 5.0E+11 }
  v2: (bool){ true }
  v3: (float){ 0.6666666666666666666666666666666667 }
  v5: (int){ 0 }
  e0: (_|_){
    // [eval] e0: invalid operands 2 and "a" to '+' (type int and string):
    //     ./in.cue:23:5
    //     ./in.cue:23:9
  }
  e5: (_|_){
    // [eval] e5: invalid operands 1.0 and 2 to 'div' (type float and int):
    //     ./in.cue:29:5
    //     ./in.cue:29:13
  }
  e6: (_|_){
    // [eval] e6: invalid operands 2 and 2.0 to 'rem' (type int and float):
    //     ./in.cue:30:5
    //     ./in.cue:30:11
  }
  e7: (_|_){
    // [eval] e7: invalid operands 2 and 2.0 to 'quo' (type int and float):
    //     ./in.cue:31:5
    //     ./in.cue:31:11
  }
  e8: (_|_){
    // [eval] e8: invalid operands 1.0 and 1 to 'mod' (type float and int):
    //     ./in.cue:32:5
    //     ./in.cue:32:13
  }
}
