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

Fix goals panel when no proof is active on Coq >= 8.16. #337

Merged
merged 2 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased ([main])

### Fixed
- Fix rendering of goals panel when no proof is active in Coq >= 8.16.
(PR #337)

## [1.7.1]

### Added
Expand Down
28 changes: 17 additions & 11 deletions python/coqtop.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ def subgoals(
"""Get the current set of hypotheses and goals."""
assert self.xml is not None

# Get only the focused goals
# Get the current proof state, but only include focused
# goals in the goal list.
response_main, err_main = self.call(
self.xml.subgoal( # type: ignore
GoalMode.FULL,
Expand All @@ -333,6 +334,13 @@ def subgoals(
if isinstance(response_main, Err):
return (False, response_main.msg, None, err_main)

# If success but we didn't get a CoqGoals, then there's
# no proof in progress. We can return early.
if response_main.val is None:
# If the request was success but it returned None, then
# we're not in a proof. No need to run the second query.
return (True, response_main.msg, None, err_main)

# NOTE: Subgoals ignores `gf_flag = "short"` if proof diffs are
# enabled.
# See: https://github.com/coq/coq/issues/16564
Expand All @@ -356,19 +364,17 @@ def subgoals(
if isinstance(response_extra, Err):
return (False, msgs, None, errs)

assert response_extra.val is not None, "proof state changed unexpectedly?"

# Merge goals
fg = response_main.val.fg if response_main.val is not None else []
bg, shelved, given_up = (
(
response_extra.val.bg,
response_extra.val.shelved,
response_extra.val.given_up,
)
if response_extra.val is not None
else ([], [], [])
goals = Goals(
response_main.val.fg,
response_extra.val.bg,
response_extra.val.shelved,
response_extra.val.given_up,
)

return (True, msgs, Goals(fg, bg, shelved, given_up), errs)
return (True, msgs, goals, errs)

def do_option(
self,
Expand Down
Loading