TypeConstraints.dfy(42,6): Error: RHS (of type int) not assignable to LHS (of type bool)
TypeConstraints.dfy(49,6): Error: RHS (of type int) not assignable to LHS (of type bool)
TypeConstraints.dfy(56,9): Error: RHS (of type int) not assignable to LHS (of type bool)
TypeConstraints.dfy(65,6): Error: RHS (of type bool) not assignable to LHS (of type int)
TypeConstraints.dfy(80,6): Error: RHS (of type MyInt) not assignable to LHS (of type int)
TypeConstraints.dfy(81,6): Error: RHS (of type int) not assignable to LHS (of type MyInt)
TypeConstraints.dfy(77,6): Error: RHS (of type int) not assignable to LHS (of type MyInt)
TypeConstraints.dfy(94,8): Error: the type of this local variable is underspecified
TypeConstraints.dfy(94,11): Error: the type of this local variable is underspecified
TypeConstraints.dfy(102,11): Error: type of + must be of a numeric type, a bitvector type, ORDINAL, char, a sequence type, or a set-like type (instead got bool)
TypeConstraints.dfy(136,16): Error: type of + must be of a numeric type, a bitvector type, ORDINAL, char, a sequence type, or a set-like type (instead got bool)
TypeConstraints.dfy(147,16): Error: type of + must be of a numeric type, a bitvector type, ORDINAL, char, a sequence type, or a set-like type (instead got C?)
TypeConstraints.dfy(145,16): Error: type of + must be of a numeric type, a bitvector type, ORDINAL, char, a sequence type, or a set-like type (instead got map<bool, int>)
TypeConstraints.dfy(149,16): Error: type of + must be of a numeric type, a bitvector type, ORDINAL, char, a sequence type, or a set-like type (instead got C)
TypeConstraints.dfy(176,6): Error: RHS (of type C) not assignable to LHS (of type R)
TypeConstraints.dfy(182,6): Error: RHS (of type object) not assignable to LHS (of type C)
TypeConstraints.dfy(188,6): Error: RHS (of type object) not assignable to LHS (of type R)
// TypeConstraints.dfy

/*
module _System {
  /* CALL GRAPH for module _System:
   * SCC at height 2:
   *   RotateRight
   * SCC at height 1:
   *   RotateLeft
   * SCC at height 0:
   *   nat
   */
  type string(==) = seq<char>

  type {:axiom} nat(==) = x: int
    | 0 <= x

  trait {:compile false} object { }
  /*-- non-null type
  type {:axiom} object(==) = c: object? | c != null    /*special witness*/
  */

  class {:compile false} array<arg> {
    var Length: int  // immutable
  }
  /*-- non-null type
  type {:axiom} array(==)<arg> = c: array?<arg> | c != null    /*special witness*/
  */

  class {:compile false} /*_#Func0*/ () ~> +R {
    function requires(): bool
      reads reads()

    function reads(): set<object?>
      reads reads()
  }

  type {:compile false} /*_#PartialFunc0*/ () --> +R = f: () ~> R
    | f.reads() == {}
    /*special witness*/

  type {:compile false} /*_#TotalFunc0*/ () -> +R = f: () --> R
    | f.requires()
    /*special witness*/

  class {:compile false} /*_#Func1*/ -T0 ~> +R {
    function requires(x0: T0): bool
      reads reads(x0)

    function reads(x0: T0): set<object?>
      reads reads(x0)
  }

  type {:compile false} /*_#PartialFunc1*/ -T0 --> +R = f: T0 ~> R
    | forall x0: T0 :: f.reads(x0) == {}
    /*special witness*/

  type {:compile false} /*_#TotalFunc1*/ -T0 -> +R = f: T0 --> R
    | forall x0: T0 :: f.requires(x0)
    /*special witness*/

  datatype {:compile false} /*_tuple#2*/ (+T0, +T1) = _#Make2(0: T0, 1: T1)

  type bool { }

  type int { }

  type real {
    var Floor: int  // immutable
  }

  type ORDINAL {
    var IsLimit: bool  // immutable
    var IsSucc: bool  // immutable
    var Offset: int  // immutable
    var IsNat: bool  // immutable
  }

  type bv {
    function method RotateLeft(w: nat): selftype

    function method RotateRight(w: nat): selftype
  }

  type map<T, U> {
    var Keys: set<T>  // immutable
    var Values: set<U>  // immutable
    var Items: set<(T, U)>  // immutable
  }

  type imap<T, U> {
    var Keys: iset<T>  // immutable
    var Values: iset<U>  // immutable
    var Items: iset<(T, U)>  // immutable
  }

  datatype /*_tuple#0*/ () = _#Make0
}
// bitvector types in use:
*/

/* CALL GRAPH for module _module:
 */

module Tests {
  /* CALL GRAPH for module Tests:
   * SCC at height 4:
   *   CC.M
   * SCC at height 3:
   *   ChainOfAssignments
   * SCC at height 2:
   *   CC.N
   * SCC at height 1:
   *   CC.F
   * SCC at height 0:
   *   nat
   */
  class CC {
    var f: nat
    var g: int

    function method F(): nat

    method M()
    {
      var a: nat := f;
      var b: int := g;
      var c: nat := F();
      var w: nat;
      var d: nat := N(w);
    }

    method N(m: nat) returns (n: nat)
  }
  /*-- non-null type
  type {:axiom} CC(==) = c: CC? | c != null    /*special witness*/
  */

  method ChainOfAssignments() returns (x: int, y: int, n: nat)
  {
    var a: int;
    var b: int := a;
    var c: int := b;
    x := c;
    y := x;
    var k: int, l: int, m: int;
    k := l;
    l := m;
    m := x;
    var p: nat, q: nat;
    p := q;
    q := n;
  }
}

module HereAreErrors {
  /* CALL GRAPH for module HereAreErrors:
   * SCC at height 1:
   *   Literals
   * SCC at height 0:
   *   MyInt
   */
  newtype MyInt = x: int
    | true

  method Error0() returns (x: int, z: bool)
  {
    var a: int, b: int, c: int;
    a, b := b, c;
    x := a;
    z := c;
  }

  method Error1() returns (x: int, z: bool)
  {
    var a: int, b: int, c: int;
    a, b := b, c;
    z := c;
    x := a;
  }

  method Error2() returns (x: int, z: bool)
  {
    var a: int, b: bool, c: int;
    a, b := c, c;
    x := a;
    z := b;
  }

  method Error3() returns (x: int, z: bool)
  {
    var a: int, b: bool, c: int;
    c := a;
    c := b;
    x := a;
    z := b;
  }

  method Literals() returns (r: int, s: MyInt)
  {
    var a: int := 0;
    var b: int := 0;
    r := a;
    s := b;
    a := b;
    b := a;
    r := s;
    s := r;
    var d: int, e: int;
    d, e := e, b;
  }
}

module PL {
  /* CALL GRAPH for module PL:
   * SCC at height 0:
   *   PlainLiterals
   */
  method PlainLiterals()
  {
    var x: int := 0;
    var r: real := 0.0;
  }
}

module PlusTests {
  /* CALL GRAPH for module PlusTests:
   */
  method Plus0()
  {
    var a, b, c;
    a := b + c;
  }
}

module PlusTests' {
  /* CALL GRAPH for module PlusTests':
   * SCC at height 1:
   *   Plus5
   * SCC at height 0:
   *   MyInt
   */
  newtype MyInt = x: int
    | true

  method Plus1()
  {
    var a: bool;
    var b: bool, c: bool;
    a := b + c;
    a := true;
  }

  method Plus2()
  {
    var a: int, b: int, c: int;
    a := b + c;
    a := 0;
  }

  method Plus3() returns (r: int)
  {
    var a: int, b: int, c: int;
    a := b + c;
    a := r;
  }

  method Plus4() returns (r: int)
  {
    var a: int, b: int, c: int;
    a := b + c;
    r := a;
  }

  method Plus5(y: MyInt)
  {
    var a: MyInt, b: MyInt, c: MyInt;
    a := b + c;
    a := y;
  }
}

module MorePlusTests {
  /* CALL GRAPH for module MorePlusTests:
   * SCC at height 2:
   *   Plusses
   * SCC at height 1:
   *   C
   * SCC at height 0:
   *   MyInt
   */
  newtype MyInt = x: int
    | true

  class C { }
  /*-- non-null type
  type {:axiom} C(==) = c: C? | c != null    /*special witness*/
  */

  method Plusses(b: bool, i: int, j: MyInt, r: real)
  {
    var ii: int := i + i;
    var jj: MyInt := j + j;
    var bb: bool := b + b;
    var rr: real := r + r;
    var s: set<bool> := {false};
    var ss: set<bool> := s + s;
    var m: multiset<bool> := multiset{false, false};
    var mm: multiset<bool> := m + m;
    var q: seq<bool> := [false];
    var qq: seq<bool> := q + q;
    var p: map<bool, int> := map[false := 17];
    var pp: map<bool, int> := p + p;
    var n: C := null;
    var nn: C? := n + n;
    var c: C := new C;
    var cc: C := c + c;
  }
}

module References {
  /* CALL GRAPH for module References:
   * SCC at height 8:
   *   M3
   * SCC at height 7:
   *   M2
   * SCC at height 6:
   *   M1
   * SCC at height 5:
   *   M0
   * SCC at height 4:
   *   M
   * SCC at height 3:
   *   K
   * SCC at height 2:
   *   object
   * SCC at height 1:
   *   R
   * SCC at height 0:
   *   C
   */
  class C extends K, M { }
  /*-- non-null type
  type {:axiom} C(==) = c: C? | c != null    /*special witness*/
  */

  trait R { }
  /*-- non-null type
  type {:axiom} R(==) = c: R? | c != null    /*special witness*/
  */

  trait K { }
  /*-- non-null type
  type {:axiom} K(==) = c: K? | c != null    /*special witness*/
  */

  trait M { }
  /*-- non-null type
  type {:axiom} M(==) = c: M? | c != null    /*special witness*/
  */

  method M0() returns (c: C, r: R)
  {
    var o: object, k: K, m: M;
    o := o;
    c := c;
    r := r;
    k := c;
    m := c;
    o := c;
    o := r;
    o := k;
    o := m;
  }

  method M1() returns (c: C, r: R)
  {
    r := c;
  }

  method M2() returns (c: C, r: R)
  {
    var o: object;
    c := o;
  }

  method M3() returns (c: C, r: R)
  {
    var o: object;
    r := o;
  }
}

module SimpleClassesAndTraits {
  /* CALL GRAPH for module SimpleClassesAndTraits:
   * SCC at height 4:
   *   Infer
   * SCC at height 3:
   *   D
   * SCC at height 2:
   *   K
   * SCC at height 1:
   *   object
   * SCC at height 0:
   *   C
   */
  class C extends K, M { }
  /*-- non-null type
  type {:axiom} C(==) = c: C? | c != null    /*special witness*/
  */

  class D extends K, M { }
  /*-- non-null type
  type {:axiom} D(==) = c: D? | c != null    /*special witness*/
  */

  trait R { }
  /*-- non-null type
  type {:axiom} R(==) = c: R? | c != null    /*special witness*/
  */

  trait K {
    var h: int
  }
  /*-- non-null type
  type {:axiom} K(==) = c: K? | c != null    /*special witness*/
  */

  trait M { }
  /*-- non-null type
  type {:axiom} M(==) = c: M? | c != null    /*special witness*/
  */

  method Infer(c: C, o: object, k: K, d: D)
      returns (k': K)
  {
    var delayme: object := c;
    var x: C := c;
    var yy: int := x.h;
    delayme := o;
    var u: K := k;
    var v: object := k;
    v := o;
    v := c;
    var w: K := c;
    w := k;
    var z: object := c;
    z := o;
    var p: object := o;
    var y: C;
    var d: C := y;
    var n: object? := null;
    var n': K? := null;
    n' := k;
    var n'': K? := null;
    k' := n'';
  }
}

module TypeParameters {
  /* CALL GRAPH for module TypeParameters:
   * SCC at height 0:
   *   M
   */
  type A

  type B

  type C<T, U>

  method M<G, H>(a: A, b: B, c0: C<int, bool>, g: G)
      returns (c1: C<real, real>, h: H)
  {
    var x: A := a;
    var y: B, z: B;
    y := z;
    z := b;
    var m: C<int, bool>, n: C<int, bool>;
    n := m;
    m := c0;
    var k: C<real, real>, l: C<real, real>;
    k := l;
    c1 := k;
    var g': G := g;
    var h': H, h'': H;
    h' := h;
    h := h'';
    var r: C<real, real>;
    r := c1;
  }
}

module Datatypes {
  /* CALL GRAPH for module Datatypes:
   * SCC at height 3:
   *   P
   * SCC at height 2:
   *   Record
   * SCC at height 1:
   *   M
   * SCC at height 0:
   *   Color
   */
  datatype Color = Red | Green | Blue

  datatype Record<T, U> = Record(t: T, u: U)

  method M() returns (c: Color)
  {
    var x: Color := c;
    var y: Color := x;
    var w: Color, z: Color;
    w := z;
    c := w;
  }

  method P() returns (r: Record<int, bool>)
  {
    var a: Record<int, bool> := r;
    var b: int, c: Record<int, bool>;
    b := r.t;
    r := c;
    var s: Record<int, real>;
    var x: int, y: real := s.t, s.u;
    x := 5;
    y := 10.0;
    var t: Record<bool, char>;
    var tt: bool, uu: char;
    tt, uu := t.t, t.u;
  }
}

module TraitStuff {
  /* CALL GRAPH for module TraitStuff:
   * SCC at height 3:
   *   Aggregate._ctor
   * SCC at height 2:
   *   PartZ
   * SCC at height 1:
   *   PartY
   * SCC at height 0:
   *   PartX
   */
  trait Part {
    var id: int
  }
  /*-- non-null type
  type {:axiom} Part(==) = c: Part? | c != null    /*special witness*/
  */

  trait Motorized { }
  /*-- non-null type
  type {:axiom} Motorized(==) = c: Motorized? | c != null    /*special witness*/
  */

  class PartX extends Part { }
  /*-- non-null type
  type {:axiom} PartX(==) = c: PartX? | c != null    /*special witness*/
  */

  class PartY extends Part, Motorized { }
  /*-- non-null type
  type {:axiom} PartY(==) = c: PartY? | c != null    /*special witness*/
  */

  class PartZ extends Part, Motorized { }
  /*-- non-null type
  type {:axiom} PartZ(==) = c: PartZ? | c != null    /*special witness*/
  */

  class Aggregate {
    ghost var Repr: set<object>
    var x: PartX
    var y: PartY
    var z: PartZ

    constructor ()
    {
      x := new PartX;
      y := new PartY;
      z := new PartZ;
      Repr := {this, x, y, z};
      new;
      var parts: set<Part> := {x, y};
      var ooo: set<object> := {y, z};
    }
  }
  /*-- non-null type
  type {:axiom} Aggregate(==) = c: Aggregate? | c != null    /*special witness*/
  */
}

module OtherTraitsAndClasses {
  /* CALL GRAPH for module OtherTraitsAndClasses:
   * SCC at height 13:
   *   Q0
   * SCC at height 12:
   *   Basics
   * SCC at height 11:
   *   Q1
   * SCC at height 10:
   *   MyClass
   * SCC at height 9:
   *   M
   * SCC at height 8:
   *   nat
   * SCC at height 7:
   *   G
   * SCC at height 6:
   *   object
   * SCC at height 5:
   *   Displays
   * SCC at height 4:
   *   K
   * SCC at height 3:
   *   J
   * SCC at height 2:
   *   E
   * SCC at height 1:
   *   D
   * SCC at height 0:
   *   C
   */
  trait J { }
  /*-- non-null type
  type {:axiom} J(==) = c: J? | c != null    /*special witness*/
  */

  trait K { }
  /*-- non-null type
  type {:axiom} K(==) = c: K? | c != null    /*special witness*/
  */

  class C extends J { }
  /*-- non-null type
  type {:axiom} C(==) = c: C? | c != null    /*special witness*/
  */

  class D extends J, K { }
  /*-- non-null type
  type {:axiom} D(==) = c: D? | c != null    /*special witness*/
  */

  class E { }
  /*-- non-null type
  type {:axiom} E(==) = c: E? | c != null    /*special witness*/
  */

  class MyClass { }
  /*-- non-null type
  type {:axiom} MyClass(==) = c: MyClass? | c != null    /*special witness*/
  */

  method Basics(x: int) returns (y: int)
  {
    var k: int := x;
    var m: int;
    y := m + m;
  }

  method Displays(c: C, d: D, e: E, j: J, k: K)
  {
    var s: set<C> := {c, c};
    var t: set<J> := {c, j};
    var t': set<J> := {j, c};
    var u: set<J> := {c, d};
    var v: set<object> := {c, e};
    var w: set<object> := {k, c};
  }

  method G(c: C)
  {
    var s: set<C> := {c};
    var t: set<C> := s;
    var u: set<object> := s;
  }

  method M() returns (r: nat)
  {
    var x: nat, y: nat, z: bool, w: int;
    x := x + y;
    z := true;
    y := r;
    w := 0;
  }

  method Q0(s: set<char>) returns (t: set<char>)
  {
    var p: set<char> := s + t;
  }

  method Q1<T>(s: set<MyClass>) returns (t: set<MyClass>)
  {
    var p: set<MyClass> := s + t;
    var q: set<object> := s + t;
  }
}

module LetPatterns {
  /* CALL GRAPH for module LetPatterns:
   * SCC at height 3:
   *   Q
   * SCC at height 2:
   *   P
   * SCC at height 1:
   *   M
   * SCC at height 0:
   *   MyDt
   */
  datatype MyDt = AAA(x: int) | BBB(y: int)

  function M(m: MyDt): int
    requires m.AAA?
  {
    var AAA(u: int) := m;
    u
  }

  method P()
  {
    var v: int;
    var m: MyDt;
    var w: int := v + var AAA(u: int) := m; u;
  }

  method Q(x: int, r: real)
  {
    var o: real;
    var u: (int, real) := (x, o);
    o := r;
  }
}

module Arrays_and_SubsetTypes {
  /* CALL GRAPH for module Arrays_and_SubsetTypes:
   * SCC at height 2:
   *   M
   * SCC at height 1:
   *   array
   * SCC at height 0:
   *   nat
   */
  method M()
  {
    var a: array<nat>;
    var b: array<int>;
    if * {
      a := new nat[100];
      b := new nat[100];
    } else if * {
      a := new int[100];
      b := new int[100];
    } else if * {
      a := b;
    } else if * {
      b := a;
    } else if * {
      var n: array<nat> := new nat[100];
      if * {
        a := n;
      } else {
        b := n;
      }
    }
  }
}
17 resolution/type errors detected in TypeConstraints.dfy
