Skip to content

Commit

Permalink
use MissingTracedValue instead of LoopInitializer
Browse files Browse the repository at this point in the history
  • Loading branch information
jumerckx committed Nov 25, 2024
1 parent 737dd69 commit de8fdbf
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/ReactantCore/src/ReactantCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ export @trace, MissingTracedValue
# Traits
is_traced(x) = false

# Special value to signify that a loop variable is uninitialized
struct LoopInitializer end

# New Type signifying that a value is missing
mutable struct MissingTracedValue
paths::Tuple
Expand Down Expand Up @@ -156,13 +153,13 @@ function trace_for(mod, expr)

potentially_undefined = setdiff(body_symbols.assignments, body_symbols.references)
defs = [gensym(arg) for arg in potentially_undefined]
inits = [Expr(:(=), def, LoopInitializer()) for (def, arg) in zip(defs, potentially_undefined)]
inits = [Expr(:(=), def, MissingTracedValue()) for (def, arg) in zip(defs, potentially_undefined)]
assigns = [Expr(:(&&), (Expr(:isdefined, arg), Expr(:(=), def, arg))) for (def, arg) in zip(defs, potentially_undefined)]

updates = []
for (def, arg) in zip(defs, potentially_undefined)
append!(updates, (quote
!($def isa $(LoopInitializer)) && ($def = $arg)
!($def isa $(MissingTracedValue)) && ($def = $arg)
end).args)
end

Expand Down

0 comments on commit de8fdbf

Please sign in to comment.