feat: ensure no unassigned metavariables in the declaration header when type is explicitly provided

This commit is contained in:
Leonardo de Moura 2021-01-11 16:40:14 -08:00
parent 3852ee16a0
commit 36008271ea
7 changed files with 20 additions and 8 deletions

View file

@ -102,9 +102,14 @@ private def elabHeaders (views : Array DefView) : TermElabM (Array DefViewElabHe
elabBinders (catchAutoBoundImplicit := true) view.binders.getArgs fun xs => do
let refForElabFunType := view.value
elabFunType refForElabFunType xs view fun xs type => do
let type ← mkForallFVars (← read).autoBoundImplicits.toArray type
let mut type ← mkForallFVars (← read).autoBoundImplicits.toArray type
let xs ← addAutoBoundImplicits xs
let levelNames ← getLevelNames
if view.type?.isSome then
Term.synthesizeSyntheticMVarsNoPostponing
type ← instantiateMVars type
let pendingMVarIds ← getMVars type
discard <| logUnassignedUsingErrorInfos pendingMVarIds
let newHeader := {
ref := view.ref,
modifiers := view.modifiers,

View file

@ -21,7 +21,7 @@ def check : Tree → UInt32
def minN := 4
def out (s) (n : Nat) (t : UInt32) : IO Unit :=
def out (s : String) (n : Nat) (t : UInt32) : IO Unit :=
IO.println (s ++ " of depth " ++ toString n ++ "\t check: " ++ toString t)
-- allocate and check lots of trees

View file

@ -1,4 +1,4 @@
--
def f1 := id

View file

@ -3,10 +3,6 @@ holeErrors.lean:3:10: error: don't know how to synthesize implicit argument
context:
⊢ Sort u_1
holeErrors.lean:3:7: error: failed to infer definition type
holeErrors.lean:5:14: error: don't know how to synthesize implicit argument
@id ?m
context:
⊢ Sort u_1
holeErrors.lean:5:9: error: failed to infer definition type
holeErrors.lean:8:9: error: don't know how to synthesize implicit argument
@id ?m

View file

@ -419,5 +419,5 @@ def f3 x y :=
theorem f3eq x y : f3 x y = x + y + 1 :=
rfl
def f4 x y : String :=
def f4 (x y : Nat) : String :=
if x > y + 1 then "hello" else "world"

View file

@ -0,0 +1,5 @@
theorem ex1 : 1 + 1 = _ := -- Error
show 1 + 1 = 2 by rfl
def ex2 : 1 + 1 = _ := -- Error
show 1 + 1 = 2 by rfl

View file

@ -0,0 +1,6 @@
theoremType.lean:1:22: error: don't know how to synthesize placeholder
context:
⊢ Nat
theoremType.lean:4:18: error: don't know how to synthesize placeholder
context:
⊢ Nat