Compare commits

...

2 Commits

Author SHA1 Message Date
Leonardo de Moura
32757026eb chore: fix test 2025-08-13 19:09:53 -07:00
Leonardo de Moura
83cff20d8c fix: panic at invalid pattern in grind
This PR fixes a panic when an invalid pattern is provided to `grind`.

closes #9899
2025-08-13 19:06:47 -07:00
3 changed files with 8 additions and 2 deletions

View File

@@ -706,7 +706,7 @@ private partial def go (pattern : Expr) (inSupport : Bool) (root : Bool) : M Exp
else
return mkOffsetPattern e k
let some f getPatternFn? pattern inSupport root .relevant
| throwError "invalid pattern, (non-forbidden) application expected{indentExpr pattern}"
| throwError "invalid pattern, (non-forbidden) application expected{indentD (ppPattern pattern)}"
assert! f.isConst || f.isFVar
unless f.isConstOf ``Grind.eqBwdPattern do
saveSymbol f.toHeadIndex

View File

@@ -0,0 +1,6 @@
namespace List
-- Should not panic
#guard_msgs (drop error) in
theorem countP_filterMap' {p : β Bool} {f : α Option β} {l : List α} :
countP p (filterMap f l) = countP (fun a => ((f a).map p).getD false) l := by
induction l with grind [=_ Option.getD_map]

View File

@@ -115,7 +115,7 @@ grind_pattern hThm1 => plus a c, plus a b
/--
error: invalid pattern, (non-forbidden) application expected
#4 #3
And #4 #3
-/
#guard_msgs (error) in
grind_pattern And.imp_left => a b