-
Notifications
You must be signed in to change notification settings - Fork 18
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
Asterisk parameters are lost #98
Comments
As is obligatory, here's a spec it 'correctly generates constants in nested classes' do
YARD.parse_string(<<-RUBY)
class A
def foo(*); end
def bar(baz, *); end
end
RUBY
expect(subject.generate.strip).to eq fix_heredoc(<<-RUBY)
# typed: strong
class A
# sord omit - no YARD type given for "_", using T.untyped
# sord omit - no YARD return type given, using T.untyped
sig { params(_: T.untyped).returns(T.untyped) }
def foo(*_); end
# sord omit - no YARD type given for "_", using T.untyped
# sord omit - no YARD type given for "baz", using T.untyped
# sord omit - no YARD return type given, using T.untyped
sig { params(baz: T.untyped, _: T.untyped).returns(T.untyped) }
def bar(baz, *_); end
end
RUBY
end |
irb(main):001:0> def meth(x, y, z); end
=> :meth
irb(main):002:0> method(:meth).parameters
=> [[:req, :x], [:req, :y], [:req, :z]]
irb(main):003:0> def meth2(x, y, z, *); end
=> :meth2
irb(main):004:0> method(:meth2).parameters
=> [[:req, :x], [:req, :y], [:req, :z], [:rest]] |
Nice catch - this seems like a YARD problem. I can't find an existing issue about this so I'll open one. |
I'm not sure if this is related, but it seems like |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Apparently Ruby accepts
*
as a parameter, for some reason. Sord doesn't currently handle this correctly.To Reproduce
Run Sord on a file like so (these two methods are from optparse.rb https://github.com/ruby/ruby/blob/trunk/lib/optparse.rb):
Expected behavior
Actual behavior
The reason I say it should return
*_
is because that's how it was resolved in sorbet. That's just a limitation of Sorbet since the params would strip the*
, so it needs to be represented as*_
.The text was updated successfully, but these errors were encountered: