Skip to content

Commit 8e7bac9

Browse files
authored
setup _INACTIVE_EXCEPTION, which can be distinguished from thrown objects (#482)
Previously `FrameData.last_exception` is initialized with `nothing`, which can't be distinguished from thrown objects, which technically can be `nothing` as well. This PR setups `_INACTIVE_EXCEPTION` singleton type and make `FrameData.last_exception` initialized with it.
1 parent 2e3c091 commit 8e7bac9

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "JuliaInterpreter"
22
uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
3-
version = "0.8.15"
3+
version = "0.8.16"
44

55
[deps]
66
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"

docs/src/dev_reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ JuliaInterpreter.dummy_breakpoint
7676
Frame
7777
JuliaInterpreter.FrameCode
7878
JuliaInterpreter.FrameData
79+
JuliaInterpreter._INACTIVE_EXCEPTION
7980
JuliaInterpreter.FrameInstance
8081
JuliaInterpreter.BreakpointState
8182
JuliaInterpreter.BreakpointRef

src/construct.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,15 @@ function prepare_framedata(framecode, argvals::Vector{Any}, lenv::SimpleVector=e
299299
resize!(sparams, 0)
300300
empty!(exception_frames)
301301
resize!(last_reference, ns)
302-
last_exception[] = nothing
302+
last_exception[] = _INACTIVE_EXCEPTION.instance
303303
else
304304
locals = Vector{Union{Nothing,Some{Any}}}(nothing, ns)
305305
ssavalues = Vector{Any}(undef, ng)
306306
sparams = Vector{Any}(undef, 0)
307307
exception_frames = Int[]
308308
last_reference = Vector{Int}(undef, ns)
309309
callargs = Any[]
310-
last_exception = Ref{Any}(nothing)
310+
last_exception = Ref{Any}(_INACTIVE_EXCEPTION.instance)
311311
end
312312
fill!(last_reference, 0)
313313
if isa(framecode.scope, Method)

src/types.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,14 @@ struct FrameData
187187
callargs::Vector{Any} # a temporary for processing arguments of :call exprs
188188
end
189189

190+
"""
191+
_INACTIVE_EXCEPTION
192+
193+
Represents a case where no exceptions are thrown yet.
194+
End users will not see this singleton type, otherwise it usually means there is missing
195+
error handling in the interpretation process.
196+
"""
197+
struct _INACTIVE_EXCEPTION end
190198

191199
"""
192200
`Frame` represents the current execution state in a particular call frame.

0 commit comments

Comments
 (0)