Skip to content
Open
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
13 changes: 11 additions & 2 deletions src/parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ function parse_function(lhs::Union{Symbol, Expr}, rhs::Expr; autovec::Bool=true,
lhs = QuoteNode(lhs)

src = Symbol[]
bound = Symbol[]
MacroTools.postwalk(rhs) do x
if @capture(x, (fn_(args__)) | (fn_.(args__))) && fn != :esc
args = args[isa.(args, Symbol)]
Expand All @@ -149,11 +150,19 @@ function parse_function(lhs::Union{Symbol, Expr}, rhs::Expr; autovec::Bool=true,
push!(src, value)
end
end
end
elseif x isa Expr && (x.head == :generator || x.head == :comprehension)
for it in x.args[2:end] # iterator clauses
if it isa Expr && ((it.head == :in) || (it.head == :(=)))
var, coll = it.args
var isa Symbol && push!(bound, var) # loop variable
coll isa Symbol && push!(src, coll) # collection column
end
end
end
return x
end

src = unique(src)
src = unique(filter(s -> s ∉ bound, src))
func_left = :($(src...),)

if autovec
Expand Down
Loading