Skip to content

Commit

Permalink
feat: fail if suggestions is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
thorimur committed Sep 20, 2023
1 parent ef6e153 commit d9abcff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions Std/Tactic/TryThis.lean
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ The parameters are:
def addSuggestions (ref : Syntax) (suggestions : Array Suggestion)
(origSpan? : Option Syntax := none)
(header : String := "Try these:") : MetaM Unit := do
if suggestions.isEmpty then throwErrorAt ref "no suggestions available"
let msgs := suggestions.map toMessageData
let msgs := msgs.foldl (init := MessageData.nil) (fun msg m => msg ++ m!"\n• " ++ m)
logInfoAt ref m!"{header}{msgs}"
Expand Down
4 changes: 4 additions & 0 deletions test/tryThis.lean
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,7 @@ info: Grab bag:
postInfo? := " at 0.166667.",
style? := some (.value (1/6))}
] with_header "Grab bag:"

/-- error: no suggestions available -/
#guard_msgs in
#demo #[]

0 comments on commit d9abcff

Please sign in to comment.