choice1.golden 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ********** source program **********
  2. choice Ints {
  3. alt None ();
  4. alt One Int;
  5. alt Two (0 = Int, 1 = Int);
  6. }
  7. fn main () -> Int {
  8. var auto: x = Ints.None();
  9. var auto: y = Ints.One(0 = 42);
  10. var auto: n = 0;
  11. match (y) {
  12. case Ints.None =>
  13. n = (n + 2);
  14. case Ints.One(0 = auto: x) =>
  15. n = ((x + 1) - 42);
  16. case Ints.Two(0 = auto: a, 1 = auto: b) =>
  17. n = 2;
  18. }
  19. match (x) {
  20. case Ints.One(0 = auto: x) =>
  21. n = (x + 2);
  22. case Ints.None() =>
  23. n = (n - 1);
  24. case Ints.Two(0 = auto: x, 1 = auto: y) =>
  25. n = 5;
  26. }
  27. return n;
  28. }
  29. choice MoreInts {
  30. alt None ();
  31. alt One Int;
  32. alt Two (0 = Int, 1 = Int);
  33. }
  34. ********** type checking **********
  35. --- step exp () --->
  36. --- step exp Int --->
  37. --- step exp (0 = Int, 1 = Int) --->
  38. --- step exp Int --->
  39. --- handle value Int with (0 = Int, 1 = Int)<1>(Int,) --->
  40. --- step exp Int --->
  41. --- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) --->
  42. --- step exp Int --->
  43. --- step exp () --->
  44. --- step exp Int --->
  45. --- step exp (0 = Int, 1 = Int) --->
  46. --- step exp Int --->
  47. --- handle value Int with (0 = Int, 1 = Int)<1>(Int,) --->
  48. --- step exp Int --->
  49. --- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) --->
  50. --- step exp Int --->
  51. --- step exp auto --->
  52. 13: type error in call
  53. expected: Int
  54. actual: Tuple(0 = Int)
  55. EXIT CODE: 255