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

Argument count is off for functions/methods when using "for"-loops #349

Closed
noctux opened this issue Aug 6, 2020 · 3 comments
Closed

Argument count is off for functions/methods when using "for"-loops #349

noctux opened this issue Aug 6, 2020 · 3 comments

Comments

@noctux
Copy link

noctux commented Aug 6, 2020

Hello,

Thank you for this nice languageserver!

When analyzing the following code:

# frozen_string_literal: true

# Print stuff reversed
def print_reverse(items)
  for i in (items.length - 1).downto(0) do
    puts items[i]
  end
end

def do_something()
  things=["a", "b", "c"]
  print_reverse(things)
end

do_something

...solargraph somehow gets confused about the arity of print_reverse, and throws an error Not enough arguments to #print_reverse (please ignore the typo in the documentation comment...):

2020-08-06-135753_849x338_scrot

The additional comma in the signature indicates that solargraph believes that there is indeed an invisible second argument to print_reverse. I'm not that familiar with ruby so there might actually be, however the code above works fine for me, and prints c\nb\na\n as expected, so I guess it's acceptable ruby?

(This is lsp-mode in emacs, I don't know how to trigger the behaviour at the cli alone, sorry)

The issue happened to me for various functions, all using for-loops in a bigger project.

I'm not 100% sure whether this is a valid bug or what information you need in detail, so please do ping me if you need more information.

Thank you for taking interest,
Simon

Additional Information:

  • ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
  • solargraph Version 0.39.13
  • emacs version 26.3, lsp-mode 20200804.1536
  • Gemfile.lock.txt for the dependencies

Edit: Forgot to add my .solargraph.yml. Basically the default one, but with typecheck:typed:

---
include:
- "**/*.rb"
exclude:
- spec/**/*
- test/**/*
- ".vendor/**/*"
- ".bundle/**/*"
require: []
domains: []
reporters:
- rubocop
- typecheck:typed
- require_not_found
require_paths: []
plugins: []
max_files: 5000
@castwide
Copy link
Owner

Confirmed. I'll work on a fix for the next patch release.

@noctux
Copy link
Author

noctux commented Aug 11, 2020

Perfect, thanks!

I believe it is not super urgent (rephrasing it as an .each loop works just fine), but of course it would be nice if it worked one day :)

castwide added a commit that referenced this issue Aug 11, 2020
@castwide
Copy link
Owner

Released in 0.39.14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants