Skip to content

Commit cec7f8a

Browse files
Undefined box (#1259)
* Undefined box * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * use isdefined --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent af79cee commit cec7f8a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Tracing.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,8 @@ Base.@nospecializeinfer function make_tracer(
17541754
))
17551755
end
17561756

1757+
struct UndefinedBox end
1758+
17571759
Base.@nospecializeinfer function make_tracer(
17581760
seen,
17591761
@nospecialize(prev::Core.Box),
@@ -1762,14 +1764,23 @@ Base.@nospecializeinfer function make_tracer(
17621764
@nospecialize(sharding = Sharding.NoSharding()),
17631765
kwargs...,
17641766
)
1767+
prev2 = if isdefined(prev, :contents)
1768+
prev.contents
1769+
else
1770+
UndefinedBox()
1771+
end
1772+
17651773
if mode == TracedToTypes
17661774
push!(path, Core.Box)
1767-
return make_tracer(seen, prev.contents, path, mode; sharding, kwargs...)
1775+
return make_tracer(seen, prev2, path, mode; sharding, kwargs...)
17681776
end
17691777
if mode != NoStopTracedTrack && haskey(seen, prev)
17701778
return seen[prev]
17711779
end
1772-
prev2 = prev.contents
1780+
if prev2 isa UndefinedBox
1781+
seen[prev] = prev
1782+
return prev
1783+
end
17731784
tr = make_tracer(
17741785
seen,
17751786
prev2,

0 commit comments

Comments
 (0)