fix: use eraseMacroScopes on trace classes
This commit is contained in:
parent
d77c99bd2f
commit
34eda689a1
4 changed files with 24 additions and 6 deletions
|
|
@ -11,11 +11,8 @@ import Init.Data.Array.Subarray
|
|||
import Init.Data.ToString
|
||||
namespace Lean
|
||||
|
||||
syntax "Macro.trace[" ident "]" interpolatedStr(term) : term
|
||||
|
||||
macro_rules
|
||||
| `(Macro.trace[$id] $s) => `(Macro.trace $(quote id.getId) (s! $s))
|
||||
|
||||
macro "Macro.trace[" id:ident "]" s:interpolatedStr(term) : term =>
|
||||
`(Macro.trace $(quote id.getId.eraseMacroScopes) (s! $s))
|
||||
|
||||
-- Auxiliary parsers and functions for declaring notation with binders
|
||||
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ def registerTraceClass (traceClassName : Name) : IO Unit :=
|
|||
macro "trace[" id:ident "]" s:(interpolatedStr(term) <|> term) : doElem => do
|
||||
let msg ← if s.getKind == interpolatedStrKind then `(m! $s) else `(($s : MessageData))
|
||||
`(doElem| do
|
||||
let cls := $(quote id.getId)
|
||||
let cls := $(quote id.getId.eraseMacroScopes)
|
||||
if (← Lean.isTracingEnabledFor cls) then
|
||||
Lean.addTrace cls $msg)
|
||||
|
||||
|
|
|
|||
19
tests/lean/traceClassScopes.lean
Normal file
19
tests/lean/traceClassScopes.lean
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import Lean
|
||||
|
||||
macro "t" t:interpolatedStr(term) : doElem =>
|
||||
`(Macro.trace[Meta.debug] $t)
|
||||
|
||||
macro "tstcmd" : command => do
|
||||
t "hello"
|
||||
`(example : Nat := 1)
|
||||
|
||||
set_option trace.Meta.debug true in
|
||||
tstcmd
|
||||
|
||||
open Lean Meta
|
||||
|
||||
macro "r" r:interpolatedStr(term) : doElem =>
|
||||
`(trace[Meta.debug] $r)
|
||||
|
||||
set_option trace.Meta.debug true in
|
||||
#eval show MetaM _ from do r "world"
|
||||
2
tests/lean/traceClassScopes.lean.expected.out
Normal file
2
tests/lean/traceClassScopes.lean.expected.out
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[Meta.debug] hello
|
||||
[Meta.debug] world
|
||||
Loading…
Add table
Reference in a new issue