Zulip Chat Archive

Stream: lean4

Topic: tracing in one file?


Scott Morrison (Oct 12 2022 at 06:42):

Is it possible to setup tracing in a single file?

import Lean

open Lean Elab Tactic Meta

initialize registerTraceClass `foo

def foo : TacticM Unit := do
  for f in  getLCtx do
      trace[foo] f.type

elab "foo" : tactic => foo

set_option trace.foo true
example (h : 0 < 1) (g : 37 < 42) : 3 < 7 := by foo

fails with unknown option 'trace.foo', while if I move the last two lines to a separate file it works fine. This is quite inconvenient when trying to make MWEs!

Scott Morrison (Oct 12 2022 at 06:48):

I know about dbg_trace but can't make it useful here because it won't pretty print Exprs.

Mario Carneiro (Oct 12 2022 at 08:35):

you can use sudo set_option for this

Mario Carneiro (Oct 12 2022 at 08:36):

IIUC you can use trace classes that haven't been defined yet, it's only in set_option that the trace class needs to be registered. So sudo set_option just disables the check

Mario Carneiro (Oct 12 2022 at 08:36):

You can also use Meta.debug if you just want something for test files that happens to already be declared


Last updated: Dec 20 2023 at 11:08 UTC