Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/get_names_used.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,16 @@ function is_struct_type_param(leaf)
end
end

# In the future, this may need an update for
# https://github.com/JuliaLang/JuliaSyntax.jl/issues/432
function in_for_argument_position(node)
# We must be on the LHS of a `for` `equal`.
if !has_parent(node, 2)
return false
elseif parents_match(node, (K"=", K"for"))
return child_index(node) == 1
elseif parents_match(node, (K"=", K"cartesian_iterator", K"for"))
return child_index(node) == 1
else
return in_for_argument_position(get_parent(node))
end
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ end
@testset "loops" begin
cursor = TreeCursor(SyntaxNodeWrapper("test_mods.jl"))
leaves = collect(Leaves(cursor))
@test map(get_val, filter(is_for_arg, leaves)) == [:i, :I, :j, :k]
@test map(get_val, filter(is_for_arg, leaves)) == [:i, :I, :j, :k, :k, :j, :xi, :yi]

# Tests #35
@test using_statement.(explicit_imports_nonrecursive(TestMod6, "test_mods.jl")) ==
Expand Down
8 changes: 7 additions & 1 deletion test/test_mods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Base.@kwdef struct Foo2
qr::Int = 1
end

end # TestMOd5
end # TestMod5

module TestMod6

Expand All @@ -69,6 +69,12 @@ function foo(x)
end
for (; k) in x
end

for (; k) in x, (; j) in y
end

for xi in x, yi in y
end
end

end # module
Expand Down