Skip to content

Commit

Permalink
feat: ensure #eval converts unassigned universe metavars into param…
Browse files Browse the repository at this point in the history
…eters

see #898
  • Loading branch information
leodemoura committed Dec 20, 2021
1 parent 51dc329 commit b278a20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/Lean/Elab/BuiltinCommand.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
import Lean.DocString
import Lean.Util.CollectLevelParams
import Lean.Elab.Command
import Lean.Elab.Open

Expand Down Expand Up @@ -296,10 +297,13 @@ unsafe def elabEvalUnsafe : CommandElab
let n := `_eval
let ctx ← read
let addAndCompile (value : Expr) : TermElabM Unit := do
let (value, _) ← Term.levelMVarToParam (← instantiateMVars value)
let type ← inferType value
let us := collectLevelParams {} value |>.params
let value ← instantiateMVars value
let decl := Declaration.defnDecl {
name := n
levelParams := []
levelParams := us.toList
type := type
value := value
hints := ReducibilityHints.opaque
Expand Down
4 changes: 2 additions & 2 deletions tests/lean/evalWithMVar.lean.expected.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ Sum.someRight c : Option Nat
evalWithMVar.lean:13:6-13:21: error: don't know how to synthesize implicit argument
@Sum.someRight ?m Nat c
context:
⊢ Type ?u
⊢ Type u_1
evalWithMVar.lean:13:20-13:21: error: don't know how to synthesize implicit argument
@c ?m
context:
⊢ Type ?u
⊢ Type u_1
Sum.someRight c : Option Nat
Sum.someRight c : Option Nat

0 comments on commit b278a20

Please sign in to comment.