Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(completions): variables leaking from for/with #447

Closed
mhanberg opened this issue May 8, 2024 · 0 comments · Fixed by #454 or #456
Closed

bug(completions): variables leaking from for/with #447

mhanberg opened this issue May 8, 2024 · 0 comments · Fixed by #454 or #456
Labels
bug Something isn't working completions

Comments

@mhanberg
Copy link
Collaborator

mhanberg commented May 8, 2024

Problem

variables created with the <- operator in a for expression leak outside of the block

foos = []
for foo <- foos do
 foo
end

f|

this will complete foo and foos.

Solution

This function inside _next_ls_private_compiler.ex should be changed so that it treats the call more like def/defp in the case that the last argument is is a keywordlist that has :do in it (has a do block)

In that case, the preceding 'args' are somewhat like parameters rather than arguments.

    defp expand_local(meta, fun, args, state, env) do
      # A compiler may want to emit a :local_function trace in here.
      {args, state, env} = expand_list(args, state, env)
      {{fun, meta, args}, state, env}
    end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment