@@ -201,6 +201,27 @@ def setGrindParams (stx : TSyntax `tactic) (params : Array Syntax) : TSyntax `ta
201201def getGrindParams (stx : TSyntax `tactic) : Array Syntax :=
202202 stx.raw[grindParamsPos][1 ].getSepArgs
203203
204+ /-- Filter out `+premises` from the config syntax -/
205+ def filterPremisesFromConfig (config : TSyntax ``Lean.Parser.Tactic.optConfig) : MetaM (TSyntax ``Lean.Parser.Tactic.optConfig) := do
206+ let configItems := config.raw.getArgs
207+ let filteredItems := configItems.filter fun item =>
208+ -- The structure is: null node -> configItem node -> posConfigItem node
209+ -- We need to check if this is a +premises config item
210+ if let some configItem := item[0 ]? then
211+ if let some innerItem := configItem[0 ]? then
212+ if innerItem.getKind == ``Lean.Parser.Tactic.posConfigItem then
213+ if let some ident := innerItem[1 ]? then
214+ ident.getId != `premises
215+ else
216+ true
217+ else
218+ true
219+ else
220+ true
221+ else
222+ true
223+ return ⟨config.raw.setArgs filteredItems⟩
224+
204225def mkGrindOnly
205226 (config : TSyntax ``Lean.Parser.Tactic.optConfig)
206227 (trace : Grind.Trace)
@@ -217,7 +238,8 @@ def mkGrindOnly
217238 else
218239 let param ← Grind.globalDeclToGrindParamSyntax declName kind minIndexable
219240 params := params.push param
220- let result ← `(tactic| grind $config:optConfig only)
241+ let filteredConfig ← filterPremisesFromConfig config
242+ let result ← `(tactic| grind $filteredConfig:optConfig only)
221243 return setGrindParams result params
222244
223245private def elabGrindConfig' (config : TSyntax ``Lean.Parser.Tactic.optConfig) (interactive : Bool) : TacticM Grind.Config := do
0 commit comments