-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ppSpace in elab
/macro
is ignored before constructor dot notation
#4561
Labels
bug
Something isn't working
Comments
eric-wieser
changed the title
ppSpace is ignored before constructor dot notation
ppSpace in Jun 25, 2024
elab
is ignored before constructor dot notation
eric-wieser
changed the title
ppSpace in
ppSpace in Jun 25, 2024
elab
is ignored before constructor dot notationelab
/macro
is ignored before constructor dot notation
It looks like the issue is that when Is this a bug in whitespace insertion? Or should import Lean
open Lean Lean.Parser.Command Lean.Elab.Command
elab "test_macroArg " args:macroArg* : command => do
let (stxParts, patArgs) := (← args.mapM expandMacroArg).unzip
logInfo m!"{stxParts}"
test_macroArg ppSpace term,+
-- [group✝(ppSpace), sepBy1(term, ",", ", ")]
test_macroArg x:ppSpace term,+
-- [ppSpace, sepBy1(term, ",", ", ")]
elab "use1" ppSpace term,+ : tactic => failure
elab "use2" x:ppSpace term,+ : tactic => failure
run_cmd Lean.Elab.Command.liftTermElabM do
Lean.logInfo <| ← `(tactic| use1 .succ 0) -- use1.succ✝ 0
Lean.logInfo <| ← `(tactic| use2 .succ 0) -- use2 .succ✝ 0 |
kmill
added a commit
to kmill/lean4
that referenced
this issue
Jul 2, 2024
This fixes an issue where if `ppSpace` appears in a `macro`/`elab` then it does not format with a space due to the fact that it gets wrapped as `group(ppSpace)` in the macro argument processing. Closes leanprover#4561
kmill
added a commit
to kmill/lean4
that referenced
this issue
Jul 2, 2024
This fixes an issue where if `ppSpace` appears in a `macro`/`elab` then it does not format with a space due to the fact that it gets wrapped as `group(ppSpace)` in the macro argument processing. Closes leanprover#4561
github-merge-queue bot
pushed a commit
that referenced
this issue
Jul 3, 2024
Now syntax nodes have their formatters run even if the parsers they wrap are all arity zero. This fixes an issue where if `ppSpace` appears in a `macro`/`elab` then it does not format with a space due to the fact that macro argument processing wraps this as `group(ppSpace)`, and `ppSpace` has arity zero. Implementation note: the fix is to make the `visitArgs` formatter combinator always visit the last child, even if it does not exist (in which case the visited node will be `Syntax.missing`). To compensate, parser combinators like many and optional need to be sure to keep track of whether there any children. Only optional's needed to be modified. Closes #4561
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Please put an X between the brackets as you perform the following steps:
https://github.com/leanprover/lean4/issues
Avoid dependencies to Mathlib or Batteries.
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
Using
ppSpace
in a parser does not always result in a space. As a result, syntax does not roundtrip.Context
Zulip
Steps to Reproduce
Expected behavior: Outputs
use .succ✝ 0
Actual behavior: Outputs
use.succ✝ 0
, which is invalid syntax due to the missing spaceVersions
4.10.0-nightly-2024-06-25
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.
The text was updated successfully, but these errors were encountered: