diff --git a/Std/Tactic/TryThis.lean b/Std/Tactic/TryThis.lean index 33fafbe4ec..eb2cf0f911 100644 --- a/Std/Tactic/TryThis.lean +++ b/Std/Tactic/TryThis.lean @@ -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}" diff --git a/test/tryThis.lean b/test/tryThis.lean index 32d45c02c9..e012ec8242 100644 --- a/test/tryThis.lean +++ b/test/tryThis.lean @@ -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 #[]