Skip to content

Commit

Permalink
fix iterators order in generators, fixes fonsp#1733
Browse files Browse the repository at this point in the history
  • Loading branch information
Pangoraw committed Dec 15, 2021
1 parent bbddcf5 commit e03fa63
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/analysis/ExpressionExplorer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ function explore!(ex::Expr, scopestate::ScopeState)::SymbolsState
# In a `for`, this expression comes at the end.

# This is not strictly the normal form of a `for` but that's okay
return explore!(Expr(:for, ex.args[2:end]..., ex.args[1]), scopestate)
return explore!(Expr(:for, Iterators.reverse(ex.args[2:end])..., ex.args[1]), scopestate)
elseif ex.head == :macrocall
# Early stopping, this expression will have to be re-explored once
# the macro is expanded in the notebook process.
Expand Down
1 change: 1 addition & 0 deletions test/ExpressionExplorer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Some of these @test_broken lines are commented out to prevent printing to the te
@test testee(:([a for a in b if a != 2]), [:b], [], [:(!=)], [])
@test testee(:([a for a in f() if g(a)]), [], [], [:f, :g], [])
@test testee(:([c(a) for a in f() if g(a)]), [], [], [:c, :f, :g], [])
@test testee(:([k for k in P, j in 1:k]), [:k, :P], [], [:(:)], [])

@test testee(:([a for a in a]), [:a], [], [], [])
@test testee(:(for a in a; a; end), [:a], [], [], [])
Expand Down

0 comments on commit e03fa63

Please sign in to comment.