fix: do not display implicit fields

This commit is contained in:
Leonardo de Moura 2022-03-09 12:32:11 -08:00
parent 50ae170bcc
commit 74411aa472
3 changed files with 20 additions and 4 deletions

View file

@ -68,10 +68,12 @@ where
let x := xs[indVal.numParams + i]
let a := mkIdent (← mkFreshUserName `a)
ctorArgs := ctorArgs.push a
if (← inferType x).isAppOf indVal.name then
rhs ← `($rhs ++ Format.line ++ $(mkIdent auxFunName):ident $a:ident max_prec)
else
rhs ← `($rhs ++ Format.line ++ reprArg $a)
let localDecl ← getLocalDecl x.fvarId!
if localDecl.binderInfo.isExplicit then
if (← inferType x).isAppOf indVal.name then
rhs ← `($rhs ++ Format.line ++ $(mkIdent auxFunName):ident $a:ident max_prec)
else
rhs ← `($rhs ++ Format.line ++ reprArg $a)
patterns := patterns.push (← `(@$(mkIdent ctorName):ident $ctorArgs:term*))
`(matchAltExpr| | $[$patterns:term],* => Repr.addAppParen (Format.group (Format.nest (if prec >= max_prec then 1 else 2) ($rhs:term))) prec)
alts := alts.push alt

13
tests/lean/tabulate.lean Normal file
View file

@ -0,0 +1,13 @@
inductive Vector (α : Type u) : Nat → Type u
| nil : Vector α 0
| cons : α → Vector α n → Vector α (n+1)
deriving Repr
infix:67 " :: " => Vector.cons
def tabulate (f : Fin n → α) : Vector α n :=
match n with
| 0 => Vector.nil
| n+1 => f 0 :: tabulate (f ∘ Fin.succ)
#eval tabulate fun i : Fin 5 => i

View file

@ -0,0 +1 @@
Vector.cons 0 (Vector.cons 1 (Vector.cons 2 (Vector.cons 3 (Vector.cons 4 (Vector.nil)))))