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

YARD:: Parser:: Ruby:: Method Definition Node#parameters #1015

Closed
MSP-Greg opened this issue Aug 13, 2016 · 4 comments
Closed

YARD:: Parser:: Ruby:: Method Definition Node#parameters #1015

MSP-Greg opened this issue Aug 13, 2016 · 4 comments

Comments

@MSP-Greg
Copy link
Contributor

See

https://github.com/lsegal/yard/blob/master/lib/yard/parser/ruby/ast_node.rb#L472

While investigating the issue with the -1 default value, came across the following code:

def parameters(include_block_param = true)
  params = self[1 + index_adjust]
  params = params[0] if params.type == :paren
  include_block_param ? params : params[0...-1]
end

last line in method, params[0...-1] removes an item from both ends of the array.

Hence, it seems that the line should be --

include_block_param ? params : params[0..-2]

Maybe I've been staring at code for too long...

Environment details:

  • OS: [Windows]
  • Ruby version: [2.3.2]
  • YARD version: [0.9.5]
  • Relevant software dependency/versions:
    • [NA]

I have read the Contributing Guide.

@MSP-Greg
Copy link
Contributor Author

Sorry, forgot to mention that

include_block_param ? params : params[0..-2]

passes RSpec using 2.3.2 & 2.2.4. Haven't investigated further.

@lsegal
Copy link
Owner

lsegal commented Aug 14, 2016

If changing this line passes tests, there are probably no tests for this actual functionality. It would be worth adding tests (including ones that address the issue from #894) to see if your fix resolves them.

@MSP-Greg
Copy link
Contributor Author

To clarify, the fix for percent arrays does not fix #894. Still working on that, maybe I'll get back to it today.

Re the tests, you'd probably zero right in on this one, but I'll have a look.

I did a bit more work yesterday checking into #894, as I'd like to find some more failure cases (one's complement ~ also fails), but that's as far as I've gotten. Speaking of blocks, I haven't checked if they are affected by #894. One would think not, but then again...

@lsegal
Copy link
Owner

lsegal commented Aug 26, 2024

Closing out some old issues. Given the significant age of this, it would be best to re-open with new context if it's still relevant.

@lsegal lsegal closed this as completed Aug 26, 2024
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