Skip to content

Commit

Permalink
doreimports after moving variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Pangoraw committed Sep 2, 2024
1 parent aaa835b commit 8e8641d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/runner/PlutoRunner/src/evaluation/deleting globals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ function move_vars(
old_workspace = getfield(Main, old_workspace_name)
new_workspace = getfield(Main, new_workspace_name)

do_reimports(new_workspace, module_imports_to_move)

for cell_id in cells_to_macro_invalidate
delete!(cell_expanded_exprs, cell_id)
end
foreach(unregister_js_link, cells_to_js_link_invalidate)

# TODO: delete
Core.eval(new_workspace, :(import ..($(old_workspace_name))))

Expand Down Expand Up @@ -96,6 +94,8 @@ function move_vars(
end
end

do_reimports(new_workspace, module_imports_to_move)

revise_if_possible(new_workspace)
end

Expand Down
36 changes: 36 additions & 0 deletions test/React.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1053,4 +1053,40 @@ import Pluto.Configuration: Options, EvaluationOptions
@test startswith(notebook.cells[2].output.body[:msg], "syntax:")
end
end

@testset "using .LocalModule" begin
notebook = Notebook(Cell.([
"""
begin
@eval module LocalModule
const x = :exported
export x
end
using .LocalModule
end
""",
"x"
]))
update_run!(🍭, notebook, notebook.cells)
@test notebook.cells[1] |> noerror
@test notebook.cells[2] |> noerror

output_2 = notebook.cells[2].output.body
@test contains(output_2, "exported")

setcode!(
notebook.cells[1],
"""
begin
@eval module LocalModule
const x = :not_exported
end
using .LocalModule
end
""",
)

update_run!(🍭, notebook, [notebook.cells[1]])
@test expecterror(UndefVarError(:x), notebook.cells[end])
end
end

0 comments on commit 8e8641d

Please sign in to comment.