Skip to content

Commit

Permalink
update to LoweredCodeUtils@3 (#650)
Browse files Browse the repository at this point in the history
* update to LoweredCodeUtils@3

* update test for v1.11
  • Loading branch information
aviatesk authored Jul 29, 2024
1 parent 25d95fb commit f221cb5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ InteractiveUtils = "1.10"
JuliaInterpreter = "0.9"
Libdl = "1.10"
Logging = "1.10"
LoweredCodeUtils = "2.4.5"
LoweredCodeUtils = "3"
MacroTools = "0.5.6"
Pkg = "1.10"
PrecompileTools = "1"
Expand Down
6 changes: 3 additions & 3 deletions src/toplevel/virtualprocess.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ Partially interprets statements in `src` using JuliaInterpreter.jl:
- special-cases `include` calls so that top-level analysis recursively enters the included file
"""
function partially_interpret!(interp::ConcreteInterpreter, mod::Module, src::CodeInfo)
concretize = select_statements(src)
concretize = select_statements(mod, src)
@assert length(src.code) == length(concretize)

with_toplevel_logger(interp.config; filter=(JET_LOGGER_LEVEL_DEBUG)) do @nospecialize(io)
Expand All @@ -1090,9 +1090,9 @@ function partially_interpret!(interp::ConcreteInterpreter, mod::Module, src::Cod
end

# select statements that should be concretized, and actually interpreted rather than abstracted
function select_statements(src::CodeInfo)
function select_statements(mod::Module, src::CodeInfo)
stmts = src.code
cl = LoweredCodeUtils.CodeLinks(src) # make `CodeEdges` hold `CodeLinks`?
cl = LoweredCodeUtils.CodeLinks(mod, src) # make `CodeEdges` hold `CodeLinks`?
edges = LoweredCodeUtils.CodeEdges(src, cl)

concretize = falses(length(stmts))
Expand Down
14 changes: 1 addition & 13 deletions test/toplevel/test_virtualprocess.jl
Original file line number Diff line number Diff line change
Expand Up @@ -681,18 +681,6 @@ end
@test occursin("isexpr2", get_msg(report))
end

# error handling for module usages
let res = @analyze_toplevel begin
using Base: foo
end

@test !isempty(res.res.toplevel_error_reports)
er = first(res.res.toplevel_error_reports)
@test er isa ActualErrorWrapped
@test er.err isa UndefVarError && er.err.var === :foo
@test er.file == (@__FILE__) && er.line == (@__LINE__) - 7
end

# sequential usage
let res = @analyze_toplevel begin
module foo
Expand Down Expand Up @@ -1735,7 +1723,7 @@ end
@eval global getsum() = $sum # concretization is forced
write(product) # should NOT be selected
end
slice = JET.select_statements(src)
slice = JET.select_statements(@__MODULE__, src)

found_N = found_sum = found_product = found_w = found_write = false
for (i, stmt) in enumerate(src.code)
Expand Down

0 comments on commit f221cb5

Please sign in to comment.