Skip to content

Commit 0593136

Browse files
authored
Merge pull request JuliaLang/julia#30954 from JuliaLang/backport-1.0.4
Backports for 1.0.4
2 parents 97f52d3 + afda01d commit 0593136

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/macros.jl

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,24 +135,17 @@ end
135135
extract_imports!(imports, x) = imports
136136
function extract_imports!(imports, ex::Expr)
137137
if Meta.isexpr(ex, (:import, :using))
138-
m = ex.args[1]
139-
if isa(m, Expr) && m.head === :(:)
140-
push!(imports, m.args[1].args[1])
141-
else
142-
for a in ex.args
143-
push!(imports, a.args[1])
144-
end
145-
end
138+
push!(imports, ex)
146139
elseif Meta.isexpr(ex, :let)
147140
extract_imports!(imports, ex.args[2])
148141
elseif Meta.isexpr(ex, (:toplevel, :block))
149-
for i in eachindex(ex.args)
150-
extract_imports!(imports, ex.args[i])
142+
for arg in ex.args
143+
extract_imports!(imports, arg)
151144
end
152145
end
153146
return imports
154147
end
155-
extract_imports(x) = extract_imports!(Symbol[], x)
148+
extract_imports(x) = extract_imports!(Any[], x)
156149

157150
"""
158151
@everywhere [procs()] expr
@@ -183,7 +176,7 @@ macro everywhere(ex)
183176
end
184177

185178
macro everywhere(procs, ex)
186-
imps = [Expr(:import, m) for m in extract_imports(ex)]
179+
imps = extract_imports(ex)
187180
return quote
188181
$(isempty(imps) ? nothing : Expr(:toplevel, imps...)) # run imports locally first
189182
let ex = $(Expr(:quote, ex)), procs = $(esc(procs))

test/distributed_exec.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Distributed: launch, manage
88
include(joinpath(Sys.BINDIR, "..", "share", "julia", "test", "testenv.jl"))
99

1010
@test Distributed.extract_imports(:(begin; import Foo, Bar; let; using Baz; end; end)) ==
11-
[:Foo, :Bar, :Baz]
11+
Any[:(import Foo, Bar), :(using Baz)]
1212

1313
# Test a few "remote" invocations when no workers are present
1414
@test remote(myid)() == 1

0 commit comments

Comments
 (0)