Skip to content

Commit d802426

Browse files
authored
always use QuoteNode in eval_code (#469)
* always use QuoteNode in eval_code * fix tests on older Julia versions * bump patch version
1 parent 97e15b5 commit d802426

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Project.toml

+1-1
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.10"
3+
version = "0.8.11"
44

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

src/utils.jl

+3-4
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,6 @@ function eval_code end
619619

620620
eval_code(frame::Frame, command::AbstractString) = eval_code(frame, Base.parse_input_line(command))
621621
function eval_code(frame::Frame, expr)
622-
maybe_quote(x) = (isa(x, Expr) || isa(x, Symbol)) ? QuoteNode(x) : x
623622
code = frame.framecode
624623
data = frame.framedata
625624
isexpr(expr, :toplevel) && (expr = expr.args[end])
@@ -633,9 +632,9 @@ function eval_code(frame::Frame, expr)
633632
defined_locals = findall(x -> x isa Some, data.locals)
634633
res = gensym()
635634
eval_expr = Expr(:let,
636-
Expr(:block, map(x->Expr(:(=), x...), [(v.name, maybe_quote(v.value isa Core.Box ? v.value.contents : v.value)) for v in vars])...,
637-
map(x->Expr(:(=), x...), [(Symbol("%$i"), maybe_quote(data.ssavalues[i])) for i in defined_ssa])...,
638-
map(x->Expr(:(=), x...), [(Symbol("@_$i"), maybe_quote(data.locals[i].value)) for i in defined_locals])...),
635+
Expr(:block, map(x->Expr(:(=), x...), [(v.name, QuoteNode(v.value isa Core.Box ? v.value.contents : v.value)) for v in vars])...,
636+
map(x->Expr(:(=), x...), [(Symbol("%$i"), QuoteNode(data.ssavalues[i])) for i in defined_ssa])...,
637+
map(x->Expr(:(=), x...), [(Symbol("@_$i"), QuoteNode(data.locals[i].value)) for i in defined_locals])...),
639638
Expr(:block,
640639
Expr(:(=), res, expr),
641640
Expr(:tuple, res, Expr(:tuple, [v.name for v in vars]...))

test/eval_code.jl

+6
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,9 @@ JuliaInterpreter.step_expr!(fr)
9696
@test eval_code(fr, "output") == :sym
9797
eval_code(fr, "output = :foo")
9898
@test eval_code(fr, "output") == :foo
99+
100+
let f() = GlobalRef(Main, :doesnotexist)
101+
fr = JuliaInterpreter.enter_call(f)
102+
JuliaInterpreter.step_expr!(fr)
103+
@test eval_code(fr, Symbol("%1")) == GlobalRef(Main, :doesnotexist)
104+
end

0 commit comments

Comments
 (0)