Skip to content

Commit 21a0e25

Browse files
committed
Fix a JET error regarding the existence of the local variable reducer at a certain point (#169)
* Fix a JET error regarding the existence of the local variable `reducer` at a certain point ``` ┌ var"@distributed"(__source__::LineNumberNode, __module__::Module, args::Vararg{Any}) @ Distributed /workpath/Distributed.jl/src/macros.jl:363 │ local variable `reducer` may be undefined: reducer::Any └──────────────────── ``` By the time we get to this location in the code, we know that the local variable `reducer` exists, by the following reasoning. If the number of arguments is 1, then we have already returned before this point. If the number of arguments is neither 1 nor 2, then we have already thrown an exception by this point. Thus, if we reach this line, the number of arguments must be 2. Since the number of arguments is 2, we know that we executed the `reducer = args[1]` line above, which means that `reducer` is defined. (cherry picked from commit cdb110658e0e3a89de3739b05679863fefb5b91b) * Define `reducer = identity` in the `na==1` branch (cherry picked from commit 1bc91f97a75c1ac321ed28dfca072cbabfad7b4c)
1 parent 00321e8 commit 21a0e25

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/macros.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ completion. To wait for completion, prefix the call with [`@sync`](@ref), like :
333333
macro distributed(args...)
334334
na = length(args)
335335
if na==1
336+
reducer = identity
336337
loop = args[1]
337338
elseif na==2
338339
reducer = args[1]

0 commit comments

Comments
 (0)