Skip to content

Commit

Permalink
feat: ensure no unassigned metavariables in the declaration header wh…
Browse files Browse the repository at this point in the history
…en type is explicitly provided
  • Loading branch information
leodemoura committed Jan 12, 2021
1 parent 3852ee1 commit 3600827
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/Lean/Elab/MutualDef.lean
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/bench/binarytrees.lean
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/lean/holeErrors.lean
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

--

def f1 := id

Expand Down
4 changes: 0 additions & 4 deletions tests/lean/holeErrors.lean.expected.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/lean/run/newfrontend1.lean
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 5 additions & 0 deletions tests/lean/theoremType.lean
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tests/lean/theoremType.lean.expected.out
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3600827

Please sign in to comment.