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,15): 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 or map-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 or map-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 or map-like type (instead got C?)
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 or map-like type (instead got C)
TypeConstraints.dfy(176,6): Error: RHS (of type C) not assignable to LHS (of type R)
TypeConstraints.dfy(424,8): Error: type array<nat> is not assignable to LHS (of type array<int>) (nonvariance for type parameter expects int = nat)
TypeConstraints.dfy(426,8): Error: type array<int> is not assignable to LHS (of type array<nat>) (nonvariance for type parameter expects nat = int)
TypeConstraints.dfy(429,8): Error: RHS (of type array<int>) not assignable to LHS (of type array<nat>) (nonvariance for type parameter expects nat = int)
TypeConstraints.dfy(431,8): Error: RHS (of type array<nat>) not assignable to LHS (of type array<int>) (nonvariance for type parameter expects int = nat)
TypeConstraints.dfy(450,8): Error: type array<nat> is not assignable to LHS (of type array<int>) (nonvariance for type parameter expects int = nat)
TypeConstraints.dfy(452,8): Error: type array<int> is not assignable to LHS (of type array<nat>) (nonvariance for type parameter expects nat = int)
TypeConstraints.dfy(455,8): Error: RHS (of type array<int>) not assignable to LHS (of type array<nat>) (nonvariance for type parameter expects nat = int)
TypeConstraints.dfy(457,8): Error: RHS (of type array<nat>) not assignable to LHS (of type array<int>) (nonvariance for type parameter expects int = nat)
TypeConstraints.dfy(542,9): Error: type test for type 'Cell<?>' must be from an expression assignable to it (got 'object')
TypeConstraints.dfy(559,11): Error: type cast to reference type 'Cell<?>' must be from an expression assignable to it (got 'object')
// TypeConstraints.dfy

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

  type {:axiom} nat(==,0) = 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> {
    const Length: int
  }
  /*-- non-null type
  type {:axiom} array(==)<arg> = c: array?<arg> | c != null /*special witness*/
  */

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

    ghost 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*/

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

    ghost 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*/

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

  type bool { }

  type char { }

  type int { }

  type real {
    const Floor: int
  }

  type ORDINAL {
    const IsLimit: bool
    const IsSucc: bool
    const Offset: int
    const IsNat: bool
  }

  type _bv {
    function RotateLeft(w: nat): selftype

    function RotateRight(w: nat): selftype
  }

  type set<+T> { }

  type iset<*T> { }

  type seq<+T> { }

  type multiset<+T> { }

  type map<+T, +U> {
    const Keys: set<T>
    const Values: set<U>
    const Items: set<(T, U)>
  }

  type imap<*T, +U> {
    const Keys: iset<T>
    const Values: iset<U>
    const Items: iset<(T, U)>
  }

  datatype /*_tuple#0*/ () = _#Make0

  type {:compile false} /*_#Func2*/ (-T0, -T1) ~> +R {
    ghost function requires(x0: T0, x1: T1): bool
      reads reads(x0, x1)

    ghost function reads(x0: T0, x1: T1): set<object?>
      reads reads(x0, x1)
  }

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

  type {:compile false} /*_#TotalFunc2*/ (-T0, -T1) -> +R = f: (T0, T1) --> R
    | forall x0: T0, x1: T1 :: f.requires(x0, x1)
    /*special witness*/
}
// bitvector types in use:
*/

/* CALL GRAPH for module _module:
 */

module Tests {
  /* CALL GRAPH for module Tests:
   * SCC at height 1:
   *   CC.M
   * SCC at height 0:
   *   CC
   * SCC at height 0:
   *   CC.F
   * SCC at height 0:
   *   CC.N
   * SCC at height 0:
   *   ChainOfAssignments
   */
  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;
  }

  class CC {
    var f: nat
    var g: int

    function 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)
      decreases m
  }
  /*-- non-null type
  type {:axiom} CC(==) = c: CC? | c != null /*special witness*/
  */
}

module HereAreErrors {
  /* CALL GRAPH for module HereAreErrors:
   * SCC at height 0:
   *   MyInt
   */
  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;
  }

  newtype MyInt = x: int
    | true
}

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 0:
   *   MyInt
   */
  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;
  }

  newtype MyInt = x: int
    | true
}

module MorePlusTests {
  /* CALL GRAPH for module MorePlusTests:
   * SCC at height 0:
   *   C
   * SCC at height 0:
   *   MyInt
   */
  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;
  }

  newtype MyInt = x: int
    | true

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

module References {
  /* CALL GRAPH for module References:
   * SCC at height 0:
   *   C
   * SCC at height 0:
   *   K
   * SCC at height 0:
   *   M
   * SCC at height 0:
   *   R
   */
  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, o: object)
  {
    c := o;
  }

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

  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*/
  */
}

module SimpleClassesAndTraits {
  /* CALL GRAPH for module SimpleClassesAndTraits:
   * SCC at height 1:
   *   Infer
   * SCC at height 0:
   *   C
   * SCC at height 0:
   *   D
   * SCC at height 0:
   *   K
   * SCC at height 0:
   *   M
   * SCC at height 0:
   *   R
   */
  method Infer(c: C, o: object, k: K, d: D)
      returns (k': K)
    decreases c, o, k, d
  {
    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'';
  }

  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*/
  */
}

module TypeParameters {
  /* CALL GRAPH for module TypeParameters:
   * SCC at height 0:
   *   M
   */
  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;
  }

  type A

  type B

  type C<T, U>
}

module Datatypes {
  /* CALL GRAPH for module Datatypes:
   * SCC at height 1:
   *   M
   * SCC at height 1:
   *   P
   * SCC at height 0:
   *   Color
   * SCC at height 0:
   *   Record
   */
  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;
  }

  datatype Color = Red | Green | Blue

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

module TraitStuff {
  /* CALL GRAPH for module TraitStuff:
   * SCC at height 1:
   *   Aggregate._ctor
   * SCC at height 0:
   *   Aggregate
   * SCC at height 0:
   *   Motorized
   * SCC at height 0:
   *   Part
   * SCC at height 0:
   *   PartX
   * SCC at height 0:
   *   PartY
   * SCC at height 0:
   *   PartZ
   */
  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 1:
   *   Displays
   * SCC at height 1:
   *   G
   * SCC at height 1:
   *   Q1
   * SCC at height 0:
   *   Basics
   * SCC at height 0:
   *   C
   * SCC at height 0:
   *   D
   * SCC at height 0:
   *   E
   * SCC at height 0:
   *   J
   * SCC at height 0:
   *   K
   * SCC at height 0:
   *   M
   * SCC at height 0:
   *   MyClass
   * SCC at height 0:
   *   Q0
   */
  method Basics(x: int) returns (y: int)
    decreases x
  {
    var k: int := x;
    var m: int;
    y := m + m;
  }

  method Displays(c: C, d: D, e: E, j: J, k: K)
    decreases c, d, e, j, 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)
    decreases 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>)
    decreases s
  {
    var p: set<char> := s + t;
  }

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

  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*/
  */
}

module LetPatterns {
  /* CALL GRAPH for module LetPatterns:
   * SCC at height 1:
   *   M
   * SCC at height 0:
   *   MyDt
   * SCC at height 0:
   *   P
   * SCC at height 0:
   *   Q
   */
  ghost function M(m: MyDt): int
    requires m.AAA?
    decreases m
  {
    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)
    decreases x, r
  {
    var o: real;
    var u: (int, real) := (x, o);
    o := r;
  }

  datatype MyDt = AAA(x: int) | BBB(y: int)
}

module Arrays_and_SubsetTypes {
  /* CALL GRAPH for module Arrays_and_SubsetTypes:
   */
  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;
      }
    }
  }
}

module Arrays_and_SubsetTypesOK {
  /* CALL GRAPH for module Arrays_and_SubsetTypesOK:
   */
  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;
      }
    }
  }
}

module TypeArgumentPrintTests {
  /* CALL GRAPH for module TypeArgumentPrintTests:
   * SCC at height 1:
   *   B.H
   * SCC at height 1:
   *   Cl.M
   * SCC at height 0:
   *   A
   * SCC at height 0:
   *   A.F
   * SCC at height 0:
   *   B
   * SCC at height 0:
   *   Cl
   * SCC at height 0:
   *   Tr
   */
  trait Tr<X> { }
  /*-- non-null type
  type {:axiom} Tr(==)<X> = c: Tr?<X> | c != null /*special witness*/
  */

  class Cl<Y> extends Tr<Y> {
    lemma M()
    {
      ghost var u: Tr<Y> := this;
      ghost var v: Tr<Y> := this;
    }
  }
  /*-- non-null type
  type {:axiom} Cl(==)<Y> = c: Cl?<Y> | c != null /*special witness*/
  */

  class A<X> {
    static function F(x: X): int
    {
      15
    }
  }
  /*-- non-null type
  type {:axiom} A(==)<X> = c: A?<X> | c != null /*special witness*/
  */

  class B<Y> {
    function H(y: Y, b: bool): int
      decreases b
    {
      if b then
        A<Y>.F(y)
      else
        A<Y>.F(y)
    }
  }
  /*-- non-null type
  type {:axiom} B(==)<Y> = c: B?<Y> | c != null /*special witness*/
  */
}

module PrettyPrintingBindingPowers {
  /* CALL GRAPH for module PrettyPrintingBindingPowers:
   * SCC at height 1:
   *   P
   * SCC at height 0:
   *   M
   * SCC at height 0:
   *   MyInt
   */
  method M(m: map<int, real>, n: map<int, real>, a: set<int>, b: set<int>, c: set<int>)
      returns (r: map<int, real>)
    decreases m, n, a, b, c
  {
    r := m - b - c;
    r := m - b + n;
    r := m - b + n;
    r := m - (b + c);
    r := m + n - (b + c);
    r := m + (n - (b + c));
    r := m + (n - b) - c;
    r := m + (m + n) + m;
    r := m + m + n + m;
  }

  method P()
      returns (x: int, u: MyInt, s: set<int>, e: seq<int>, m: map<int, int>)
  {
    x := x + x + x;
    u := u + (u + u);
    s := s + (s + s);
    e := e + (e + e);
    m := m + (m + m);
  }

  newtype MyInt = u: int
    | u != 193
}

module SameSCC {
  /* CALL GRAPH for module SameSCC:
   * SCC at height 0:
   *   G6
   *   G5
   *   G4
   *   G3
   *   G2
   *   G1
   *   G0
   */
  type G0 = G1

  type G1 = G2

  type G2 = G3<int>

  type G3<X> = (X, G4)

  type G4 = G5

  datatype G5 = G5(G6)

  codatatype G6 = G6(array<G0>)
}

module UnderspecifiedTypeConversions0 {
  /* CALL GRAPH for module UnderspecifiedTypeConversions0:
   * SCC at height 0:
   *   Cell
   * SCC at height 0:
   *   UCell
   */
  method M(c: Cell<int>)
  {
    if c is UCell<int, ?> {
      print "yes";
    }
  }

  method N(c: object)
  {
    if c is Cell<?> {
      print "yes";
    }
  }

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

  type UCell<U, V> = Cell<U>
}

module UnderspecifiedTypeConversions1 {
  /* CALL GRAPH for module UnderspecifiedTypeConversions1:
   * SCC at height 0:
   *   Cell
   * SCC at height 0:
   *   UCell
   */
  method M(c: Cell<int>)
  {
    var d: Cell<int>;
    d := c as UCell<int, ?>;
  }

  method N(c: object)
  {
    var d: object;
    d := c as Cell<?>;
  }

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

  type UCell<U, V> = Cell<U>
}
24 resolution/type errors detected in TypeConstraints.dfy
