AaronC81 / sord

Convert YARD docs to Sorbet RBI and Ruby 3/Steep RBS files
https://sord.aaronc.cc
MIT License
304 stars 18 forks source link

second curly bracket is removed when block is used as a param #136

Closed yratanov closed 2 years ago

yratanov commented 2 years ago

To Reproduce

class A
  def x(a: ->() {}); end
end

Expected behavior

class A
  # sord omit - no YARD type given for "a:", using untyped
  # sord omit - no YARD return type given, using untyped
  sig { params(a: T.untyped).returns(T.untyped) }
  def x(a: ->() {}); end
end

Actual behavior

class A
  # sord omit - no YARD type given for "a:", using untyped
  # sord omit - no YARD return type given, using untyped
  sig { params(a: T.untyped).returns(T.untyped) }
  def x(a: ->() {); end
end
- def x(a: ->() {); end
+ def x(a: ->() {}); end

Failing test: https://github.com/AaronC81/sord/pull/137

AaronC81 commented 2 years ago

I reckon this is because of the workaround in #127 to fix a YARD bug. The default parameter in your example kind of begins with a unary minus symbol, but it's actually a ->.

I'll take a look at this in the next couple of days! I don't think it should be too tricky to exclude this case from that workaround.

AaronC81 commented 2 years ago

Just tidying up - already fixed by #137, so closing :)