Skip to content

fix: show goal of empty nested by block at positions indented past the enclosing tactic - #15095

Merged
mhuisi merged 1 commit into
masterfrom
goals-at-hanging-by
Sep 9, 2026
Merged

mhuisi merged 1 commit into
masterfrom
goals-at-hanging-by

Conversation

@Kha

@Kha Kha commented Sep 9, 2026

Copy link
Copy Markdown
Member

This PR fixes the goal view showing the state after have instead of the goal of an empty nested have ... := by block on the following line, where the next tactic is about to be typed (#15053, regression of #1927 from #13229).

The isEmptyBy heuristic in InfoTree.goalsAt? was removed in #13229 because empty by blocks no longer produce .missing syntax. Instead of checking for emptiness, by blocks and tokens are now flagged as hangingBy, and whether they count as indented is decided by the enclosing tactic by comparing the hover column with its own column, which matches where the parser would put a tactic typed at that position.

…the enclosing tactic

This PR fixes the goal view showing the state after `have` instead of the goal of an empty nested `have ... := by` block on the following line, where the next tactic is about to be typed (#15053, regression of #1927 from #13229).

The `isEmptyBy` heuristic in `InfoTree.goalsAt?` was removed in #13229 because empty `by` blocks no longer produce `.missing` syntax. Instead of checking for emptiness, `by` blocks and tokens are now flagged as `hangingBy`, and whether they count as indented is decided by the enclosing tactic by comparing the hover column with its own column, which matches where the parser would put a tactic typed at that position.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UUFnG7QzKo9chq1i9qDkaR
@Kha
Kha requested a review from mhuisi as a code owner September 9, 2026 13:34
@github-actions github-actions Bot added toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN labels Sep 9, 2026
@mhuisi mhuisi added the changelog-server Language server, widgets, and IDE extensions label Sep 9, 2026
@mhuisi
mhuisi enabled auto-merge September 9, 2026 14:18
@mhuisi
mhuisi added this pull request to the merge queue Sep 9, 2026
Merged via the queue into master with commit 1163653 Sep 9, 2026
23 of 24 checks passed
@mathlib-lean-pr-testing mathlib-lean-pr-testing Bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Sep 9, 2026
@mathlib-lean-pr-testing

Copy link
Copy Markdown

Mathlib CI status (docs):

@Rob23oba

Rob23oba commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

This doesn't work for

example : True := by
  induction True.intro with
  | intro =>
    -- no goals

example : True := by
  cases True.intro with
  | intro =>
    -- no goals

example : True := by
  impossible by
    -- no goals

though (put your cursor before the comment). Ideally, it would just show the goal state of the goal that would be affected if you wrote sorry at the cursor position (should I make a new issue?).

Kha added a commit that referenced this pull request Sep 10, 2026
… at positions indented past the enclosing tactic (#15104)

Backport 1163653 from #15095.

Co-authored-by: Sebastian Ullrich <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
@mhuisi

mhuisi commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

@Rob23oba Does it work with #15093? (I think the impossible by issue is pre-existing and is likely due to bad TacticInfo)

@Rob23oba

Copy link
Copy Markdown
Contributor

Yes, the first and second example works properly now!

example : False := by
  grind =>
    -- no goals

example : False := by
  sym =>
    -- no goals

example : True := by
  impossible by
    -- no goals

still don't work though

@mhuisi

mhuisi commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

I don't think that these are recent regressions, either. Please feel free to open an issue about these.
(All of them look like bad TacticInfo to me)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport releases/v4.34.0 builds-mathlib CI has verified that Mathlib builds against this PR changelog-server Language server, widgets, and IDE extensions mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants