pp.all cannot round-trip applied lambdas with implicit binders
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
Please put an X between the brackets as you perform the following steps:
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. - Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
Even pp.all true seems to not be enough to print terms of the form Expr.app `(fun {x} => y) z.
Context
Steps to Reproduce
Run
import Lean
open Lean
elab "thats_illegal" : term =>
return Expr.app
(Expr.lam `n (.const `Nat []) (.bvar 0) .implicit)
(Expr.const `Nat.zero [])
set_option pp.all true
/-- info: (@fun {n : Nat} => n) Nat.zero : Nat -/
#guard_msgs in #check thats_illegal
-- copied from the output, but doesn't work!
#check ((@fun {n : Nat} => n) Nat.zero : Nat)
-- fixed by hand, but not the same expression any more
#check (@id _ (fun {n : Nat} => n) Nat.zero : Nat)
Expected behavior: The output of #check with pp.all true should round-trip
Actual behavior: The resulting expression has a type error
Versions
4.14.0-rc2
Additional Information
[Additional information, configuration or data that might be necessary to reproduce the issue]
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal Lean reproduction using pp.all true, Expr.app, and the #check commands. Compare the printed applied lambda with the hand-fixed expression and trace how pretty-printed implicit binders are parsed. Done means the #check output round-trips without a type error while preserving the intended expression.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100