Conversation
Mathlib/Util/Qq.lean
Outdated
| /-- `Lean.toExpr` with Qq support. -/ | ||
| def Lean.ToExpr.mkQ.{u} {α : Type u} [Lean.ToLevel.{u}] | ||
| (toTypeExprQ : Q(Type $(Lean.toLevel.{u}))) (toExprQ : α → Q($toTypeExprQ)) : | ||
| ToExpr α where | ||
| toTypeExpr := toTypeExprQ | ||
| toExpr x := toExprQ x |
There was a problem hiding this comment.
This definition seems to get confused with universe variables if I actually try to use it.
Mathlib/Data/Fin/Basic.lean
Outdated
| instance toExpr (n : ℕ) : Lean.ToExpr (Fin n) where | ||
| toTypeExpr := q(Fin $n) | ||
| toExpr := match n with | ||
| instance toExpr (n : ℕ) : Lean.ToExpr (Fin n) := Lean.ToExpr.mkQ.{0} |
There was a problem hiding this comment.
Without the {0} this gives
type mismatch
Fin «$n»
has type
Type : Type 1
but is expected to have type
Type 127 : Type 128
There was a problem hiding this comment.
Yes, this is the ToLevel issue I've alluded to on Zulip. Depending on the order the instances are synthesized, we can end up searching for an instance of ToLevel.{?u}. And since the succ instances has higher priority than the zero instance, we get ToLevel.{127} as a result. If we'd swap the instance priorities, we'd get ToLevel.{0}. Of course, neither choice is desirable.
|
This PR/issue depends on:
|
|
Coming here from triaging old PRs: is this PR still relevant? (I vaguely remember some material around ToExpr being upstreamed to core - that might have been something else, though.) |
ToExpr#6699 (to appease the linter)