fix: disable quotation precheck if hygiene is false

This commit is contained in:
Sebastian Ullrich 2021-04-27 18:24:52 +02:00 committed by Leonardo de Moura
parent 9301e05a7e
commit ad7ee2c81b
3 changed files with 8 additions and 7 deletions

View file

@ -18,11 +18,6 @@ open Lean.Parser.Term
open Lean.Syntax
open Meta
register_builtin_option hygiene : Bool := {
defValue := true
descr := "Annotate identifiers in quotations such that they are resolved relative to the scope at their declaration, not that at their eventual use/expansion, to avoid accidental capturing. Note that quotations/notations already defined are unaffected."
}
/-- `C[$(e)]` ~> `let a := e; C[$a]`. Used in the implementation of antiquot splices. -/
private partial def floatOutAntiquotTerms : Syntax → StateT (Syntax → TermElabM Syntax) TermElabM Syntax
| stx@(Syntax.node k args) => do

View file

@ -55,8 +55,9 @@ where
return true
return false
def runPrecheck (stx : Syntax) : TermElabM Unit :=
precheck stx |>.run { quotLCtx := {} }
def runPrecheck (stx : Syntax) : TermElabM Unit := do
if hygiene.get (← getOptions) then
precheck stx |>.run { quotLCtx := {} }
@[builtinQuotPrecheck ident] def precheckIdent : Precheck
| Syntax.ident info rawVal val preresolved => do

View file

@ -8,6 +8,11 @@ import Lean.Elab.Term
namespace Lean.Elab.Term.Quotation
open Lean.Syntax
register_builtin_option hygiene : Bool := {
defValue := true
descr := "Annotate identifiers in quotations such that they are resolved relative to the scope at their declaration, not that at their eventual use/expansion, to avoid accidental capturing. Note that quotations/notations already defined are unaffected."
}
partial def getAntiquotationIds (stx : Syntax) : TermElabM (Array Syntax) := do
let mut ids := #[]
for stx in stx.topDown do