Skip to content
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

trySuggestions (exact? etc.) can produce wrongly indented source #6626

Open
3 tasks done
b-mehta opened this issue Jan 13, 2025 · 3 comments
Open
3 tasks done

trySuggestions (exact? etc.) can produce wrongly indented source #6626

b-mehta opened this issue Jan 13, 2025 · 3 comments
Labels
bug Something isn't working P-low We are not planning to work on this issue

Comments

@b-mehta
Copy link
Contributor

b-mehta commented Jan 13, 2025

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

The result of clicking "Try this" after an exact? gives "type mismatch" and "unexpected identifier; expected command" errors.

theorem AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA :
    True → True → 1 = 2 := by 
  sorry

theorem test : 1 = 2 := by exact?

live.lean-lang.org version

Context

A student encountered this when using exact? on mathlib.

Steps to Reproduce

  1. Code as above
  2. Click the try this suggestion from exact?

Expected behavior: The result of exact? should close the goal.

Actual behavior: The result of exact? gives two errors, both of which are unhelpful to beginners.

Versions

Using live.lean-lang.org:
Lean 4.16.0-nightly-2025-01-10
Target: x86_64-unknown-linux-gnu

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@b-mehta b-mehta added the bug Something isn't working label Jan 13, 2025
@nomeata
Copy link
Collaborator

nomeata commented Jan 13, 2025

This is the source after applying the suggestion:

theorem test : 1 = 2 := by exact
  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA trivial
    trivial

The problem seems to be that the suggested output is wrapped and indented, but because the exact? was itself on the far right, the resulting code was wrong.

If we start with

theorem test : 1 = 2 := by
  exact?

it expands to

theorem test : 1 = 2 := by
  exact
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA trivial
      trivial

which works.

I have seen this before and assume that this is not exact? specific but will likewise apply to simp? etc.

@nomeata nomeata changed the title exact? suggestion gives "unexpected identifier" trySuggestions (exact? etc.) can produce wrongly indendent source Jan 13, 2025
@b-mehta
Copy link
Contributor Author

b-mehta commented Jan 13, 2025

I have seen this before and assume that this is not exact? specific but will likewise apply to simp? etc.

Indeed there is a similarity between this and #6006

@b-mehta b-mehta changed the title trySuggestions (exact? etc.) can produce wrongly indendent source trySuggestions (exact? etc.) can produce wrongly indented source Jan 13, 2025
@leanprover-bot leanprover-bot added the P-low We are not planning to work on this issue label Jan 14, 2025
@Kha
Copy link
Member

Kha commented Jan 14, 2025

This one unfortunately is much more complicated than the other issue as we would effectively need to reformat the entire by block. We want to get there with a general code formatter but it's not currently part of our roadmap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-low We are not planning to work on this issue
Projects
None yet
Development

No branches or pull requests

4 participants