-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
JET is warning about possible undefined variable when using the @timeit macro from TimerOutputs.jl.
MWE:
using TimerOutputs
using JET
module MWE
using TimerOutputs: TimerOutput, @timeit
"Simplest possible function that triggers the JET warning"
function simple_timed()
to = TimerOutput()
@timeit to "section" begin
42
end
return to
end
end
using .MWE
report_simple = @report_call target_modules = (MWE,) MWE.simple_timed()
println(report_simple
this outputs
═════ 1 possible error found ═════
┌ simple_timed() @ Main.MWE /mypath/debug_timeroutputs.jl:11
│ local variable `accumulated_data#375` may be undefined: accumulated_data#375::TimerOutputs.TimeData
└────────────────────
The @timeitmacro expansion:
@timeit timer "label" begin
body
end
expands to something like
local_timer = timer
enabled = local_timer.enabled # Bool field on TimerOutput
if enabled
accumulated_data = push!(local_timer, "label") # ← defined only here
end
t0 = time_ns()
b0 = gc_bytes()
try
body
finally
if enabled
do_accumulate!(accumulated_data, t0, b0) # ← JET warns: may be undefined
pop!(local_timer)
end
end
Should JET be able to understand that accumulated_data is never accessed when it is not defined?
Versioninfo
julia> versioninfo()
Julia Version 1.12.3
Commit 966d0af0fdf (2025-12-15 11:20 UTC)
Build Info:
Official https://julialang.org release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 12 × 12th Gen Intel(R) Core(TM) i7-1255U
WORD_SIZE: 64
LLVM: libLLVM-18.1.7 (ORCJIT, alderlake)
GC: Built with stock GC
Threads: 12 default, 1 interactive, 12 GC (on 12 virtual cores)
Environment:
JULIA_EDITOR = code
JULIA_VSCODE_REPL = 1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels