tests: add more issues

This commit is contained in:
Leonardo de Moura 2019-10-15 07:47:09 -07:00
parent 39e8499c7b
commit 0c3c5bf82f
3 changed files with 62 additions and 0 deletions

View file

@ -0,0 +1,15 @@
import Init.Data.HashMap
def f (a : HashMap Nat Nat) : HashMap Nat Nat :=
a
def t (as : List Nat) :=
let xs := {};
/- We can't elaborate r.insert at this point because we don't know the type of `r`.
Our plan is to suspend it by creating a metavariable, and resume later when we have
more information. -/
let ys := as.foldl (fun r a => r.insert a) xs;
/- After elaborating `f xs`, we learn that `xs` has type `HashMap Nat Nat`. Then,
we have enough information for resuming the elaboration of `r.insert a` -/
let zs := f xs;
ys

View file

@ -0,0 +1,14 @@
def f1 (n : Nat) (i : Int) :=
i + n -- works
def f2 (n : Nat) (i : Int) :=
n + i -- fails can't coerce Int to Nat
def f3 (n : Nat) (i : Int) :=
n + (n + (n + (n + i))) -- nested version of the previous issue
def f4 (n : Nat) (i : Int) :=
n + (n + (n * (n * i))) -- nested version of the previous issue with mixed operators
def f5 (n : Nat) (i : Int) :=
n + (n + (n * (i, i).1)) -- mixed operators and different structures

View file

@ -0,0 +1,33 @@
structure A :=
(a : Nat)
structure B :=
(a : Nat)
structure C :=
(a : Nat)
instance : HasCoe A B := ⟨fun s => ⟨s.1⟩⟩
instance : HasCoe A C := ⟨fun s => ⟨s.1⟩⟩
def f {α} (a b : α) := a
def forceB {α} (b : B) (a : α) := a
def forceC {α} (c : C) (a : α) := a
def forceA {α} (a : A) (o : α) := o
def f1 (x : _) (y : _) (z : _) :=
let a1 := f x y;
let a2 := f y z;
forceB x a1 -- works
def f2 (x : _) (y : _) (z : _) :=
let a1 := f x (coe y);
let a2 := f (coe y) z;
forceB x (forceC z (forceA y (a1, a2))) -- works because we manually added the coercions above
def f3 (x : _) (y : _) (z : _) :=
let a1 := f x y;
let a2 := f y z;
/- Fails because we "missed" the opportunity to insert coercions around `y`.
I think we should **not** support this kind of example. -/
forceB x (forceC z (forceA y (a1, a2)))