Skip to content

Commit

Permalink
fix test, change
Browse files Browse the repository at this point in the history
  • Loading branch information
kmill committed Jul 13, 2024
1 parent 99dcb90 commit cf600e0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Lean/Meta/Instances.lean
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ private partial def computeSynthOrder (inst : Expr) : MetaM (Array Nat) :=
return synthed

def addInstance (declName : Name) (attrKind : AttributeKind) (prio : Nat) : MetaM Unit := do
let type := (← getConstInfo declName).type
unless (← isClass? type).isSome do
throwError "type class instance expected{indentExpr type}"
let c ← mkConstWithLevelParams declName
let keys ← mkInstanceKey c
addGlobalInstance declName attrKind
Expand All @@ -203,9 +206,6 @@ builtin_initialize
name := `instance
descr := "type class instance"
add := fun declName stx attrKind => do
let type := (← getConstInfo declName).type
unless (← isClass? type |>.run' {} {}).isSome do
throwError "type class instance expected{indentExpr type}"
let prio ← getAttrParamOptPrio stx[1]
discard <| addInstance declName attrKind prio |>.run {} {}
erase := fun declName => do
Expand Down
2 changes: 2 additions & 0 deletions tests/lean/run/simp_proj_transparency_issue.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ structure Foo where
x : Nat
y : Nat := 10

attribute [class] Foo

@[instance]
def f (x : Nat) : Foo :=
{ x := x + x }
Expand Down
4 changes: 2 additions & 2 deletions tests/lean/synthorder.lean.expected.out
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
synthorder.lean:4:0-4:40: error: instance does not provide concrete values for (semi-)out-params
synthorder.lean:4:0-4:8: error: instance does not provide concrete values for (semi-)out-params
Foo A (B × ?C)
synthorder.lean:7:0-7:38: error: cannot find synthesization order for instance @instFooNat with type
synthorder.lean:7:0-7:8: error: cannot find synthesization order for instance @instFooNat with type
{A : Type} → [inst : Foo A Nat] → Foo Nat A
all remaining arguments have metavariables:
Foo ?A Nat
Expand Down

0 comments on commit cf600e0

Please sign in to comment.