Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to LoweredCodeUtils@3 #650

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading