Skip to content
Closed
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
14 changes: 14 additions & 0 deletions src/Lean/Elab/Tactic/Conv/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,17 @@ private def convLocalDecl (conv : Syntax) (hUserName : Name) : TacticM Unit := w
Tactic.evalFirst

end Lean.Elab.Tactic.Conv

open Lean.Parser Tactic.Conv in
/-- `set_option opt val in tacs` (the conv tactic) acts like `set_option opt val` at the command level,
but it sets the option only within the conv tactics `tacs`. -/
syntax (name := Lean.Parser.Tactic.Conv.«set_option») "set_option " ident ppSpace Lean.Parser.Command.optionValue " in " convSeq : conv

namespace Lean.Elab.Tactic.Conv

@[builtin_tactic Lean.Parser.Tactic.Conv.set_option] def elabSetOption : Tactic := fun stx => do
let options ← Elab.elabSetOption stx[1] stx[2]
withTheReader Core.Context (fun ctx => { ctx with maxRecDepth := maxRecDepth.get options, options := options }) do
evalTactic stx[4]

end Lean.Elab.Tactic.Conv
5 changes: 5 additions & 0 deletions src/Lean/Parser/Command.lean
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ but it opens a namespace only within the tactics `tacs`. -/
but it sets the option only within the tactics `tacs`. -/
@[builtin_tactic_parser] def «set_option» := leading_parser:leadPrec
"set_option " >> ident >> ppSpace >> Command.optionValue >> " in " >> tacticSeq

-- /-- `set_option opt val in tacs` (the conv tactic) acts like `set_option opt val` at the command level,
-- but it sets the option only within the conv tactics `tacs`. -/
-- @[builtin_tactic_parser] def Conv.«set_option» := leading_parser:leadPrec
-- "set_option " >> ident >> ppSpace >> Command.optionValue >> " in " >> convSeq
end Tactic

end Parser
Expand Down
21 changes: 21 additions & 0 deletions tests/lean/setOptionConv.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Lean

example
: (fun x : Nat => x + 0)
=
fun x => x
:=
by
trace_state
set_option pp.funBinderTypes true in
trace_state; trace_state
trace_state

set_option pp.funBinderTypes false in

conv =>
trace_state
set_option pp.funBinderTypes true in
trace_state; trace_state
trace_state

8 changes: 8 additions & 0 deletions tests/lean/setOptionConv.lean.expected.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
⊢ (fun x => x + 0) = fun x => x
⊢ (fun (x : Nat) => x + 0) = fun (x : Nat) => x
⊢ (fun (x : Nat) => x + 0) = fun (x : Nat) => x
⊢ (fun (x : Nat) => x + 0) = fun (x : Nat) => x
| (fun x => x + 0) = fun x => x
| (fun (x : Nat) => x + 0) = fun (x : Nat) => x
| (fun (x : Nat) => x + 0) = fun (x : Nat) => x
| (fun (x : Nat) => x + 0) = fun (x : Nat) => x