fix: parenthesizer
This commit is contained in:
parent
6f0192581a
commit
43caef0130
3 changed files with 9 additions and 14 deletions
|
|
@ -387,6 +387,7 @@ addLbp prec
|
|||
def trailingNode.parenthesizer : Parenthesizer | p => do
|
||||
stx ← getCur;
|
||||
k ← evalName $ p.getArg! 0;
|
||||
prec ← evalNat $ p.getArg! 1;
|
||||
when (k != stx.getKind) $ do {
|
||||
trace! `PrettyPrinter.parenthesize.backtrack ("unexpected node kind '" ++ toString stx.getKind ++ "', expected '" ++ toString k ++ "'");
|
||||
-- HACK; see `orelse.parenthesizer`
|
||||
|
|
@ -399,8 +400,7 @@ visitArgs $ do {
|
|||
-- parser is calling us; we only need to know its `mkParen`, which we retrieve from the context.
|
||||
{ mkParen := some mkParen, .. } ← read
|
||||
| panic! "trailingNode.parenthesizer called outside of visitParenthesizable call";
|
||||
{ minLbp := trailLbp, .. } ← get;
|
||||
visitAntiquot <|> visitParenthesizable mkParen 0 trailLbp;
|
||||
visitAntiquot <|> visitParenthesizable mkParen 0 prec;
|
||||
visit p.appArg!
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ def typeAs.{u} (α : Type u) (a : α) := ()
|
|||
#eval check `(fun (a : Nat) (b : Bool) => a)
|
||||
#eval check `(fun {a b : Nat} => a)
|
||||
-- implicit lambdas work as long as the expected type is preserved
|
||||
#eval check `(typeAs ({α : Type} → (a : α) → α) (fun a => a))
|
||||
#eval check `(typeAs ({α : Type} → (a : α) → α) fun a => a)
|
||||
section set_option pp.explicit true
|
||||
#eval check `(fun {α : Type} [HasToString α] (a : α) => toString a)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -71,18 +71,13 @@
|
|||
(Term.arrow (Term.id `α (null)) "→" (Term.id `α (null))))
|
||||
(null))
|
||||
")")
|
||||
(Term.paren
|
||||
"("
|
||||
(Term.fun
|
||||
"fun"
|
||||
(null
|
||||
(Term.fun
|
||||
"fun"
|
||||
(null
|
||||
(Term.implicitBinder "{" (null `α) (null ":" (Term.type "Type" (null))) "}")
|
||||
(Term.paren "(" (null (Term.id `a (null)) (null (Term.typeAscription ":" (Term.id `α (null))))) ")"))
|
||||
"=>"
|
||||
(Term.id `a (null)))
|
||||
(null))
|
||||
")")))
|
||||
(Term.implicitBinder "{" (null `α) (null ":" (Term.type "Type" (null))) "}")
|
||||
(Term.paren "(" (null (Term.id `a (null)) (null (Term.typeAscription ":" (Term.id `α (null))))) ")"))
|
||||
"=>"
|
||||
(Term.id `a (null)))))
|
||||
(Term.fun
|
||||
"fun"
|
||||
(null
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue