Skip to content

fix: apply? produces a non-synthetic sorry #8231

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

Merged
merged 1 commit into from
May 5, 2025
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: 2 additions & 2 deletions src/Lean/Elab/Tactic/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace Lean.Elab
open Meta

/-- Assign `mvarId := sorry` -/
def admitGoal (mvarId : MVarId) : MetaM Unit :=
def admitGoal (mvarId : MVarId) (synthetic : Bool := true): MetaM Unit :=
mvarId.withContext do
let mvarType ← inferType (mkMVar mvarId)
mvarId.assign (← mkLabeledSorry mvarType (synthetic := true) (unique := true))
mvarId.assign (← mkLabeledSorry mvarType (synthetic := synthetic) (unique := true))

def goalsToMessageData (goals : List MVarId) : MessageData :=
MessageData.joinSep (goals.map MessageData.ofGoal) m!"\n\n"
Expand Down
2 changes: 1 addition & 1 deletion src/Lean/Elab/Tactic/LibrarySearch.lean
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def exact? (ref : Syntax) (required : Option (Array (TSyntax `term))) (requireCl
addExactSuggestion ref (← instantiateMVars (mkMVar mvar)).headBeta
(checkState? := initialState) (addSubgoalsMsg := true) (tacticErrorAsInfo := true)
if suggestions.isEmpty then logError "apply? didn't find any relevant lemmas"
admitGoal goal
admitGoal goal (synthetic := false)

@[builtin_tactic Lean.Parser.Tactic.exact?]
def evalExact : Tactic := fun stx => do
Expand Down
4 changes: 4 additions & 0 deletions tests/lean/librarySearch.lean
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,7 @@ error: apply? didn't find any relevant lemmas
-/
#guard_msgs in
example {α : Sort u} (x y : α) : Eq x y := by apply?

-- Verify that there is a `sorry` warning when `apply?` closes the goal.
#guard_msgs (drop info) in
example : False := by apply?
1 change: 1 addition & 0 deletions tests/lean/librarySearch.lean.expected.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
librarySearch.lean:281:0-281:7: warning: declaration uses 'sorry'
Loading