Skip to content

Commit

Permalink
Fix: use exprToSyntax in comefrom elaborator (#28)
Browse files Browse the repository at this point in the history
The current logic to embed an expression into syntax is buggy since it doesn't unify types while doing the metavariable assignment. This can leave unassigned universe metavariables. Switching to core's `exprToSyntax` resolves this issue.

I discovered this while working on lean4#2973. Without this fix, all the `match` examples in this repository fail when using that PR's version of Lean.
  • Loading branch information
kmill authored Dec 1, 2023
1 parent d3a1d25 commit ccba5d3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Qq/Match.lean
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ partial def isIrrefutablePattern : Term → Bool

scoped elab "_comefrom" n:ident "do" b:doSeq " in " body:term : term <= expectedType => do
let _ ← extractBind expectedType
(← elabTerm (← `(?m)).1.stripPos none).mvarId!.assign expectedType
elabTerm (← `(have $n:ident : ?m := (do $b:doSeq); $body)) expectedType
let ty ← exprToSyntax expectedType
elabTerm (← `(have $n:ident : $ty := (do $b:doSeq); $body)) expectedType

scoped syntax "_comefrom" ident "do" doSeq : term
macro_rules | `(assert! (_comefrom $n do $b); $body) => `(_comefrom $n do $b in $body)
Expand Down

0 comments on commit ccba5d3

Please sign in to comment.