rbs
rbs copied to clipboard
RBS::ParsingError: Syntax error: optional keyword argument type is expected, token=`(` (pLPAREN)
I'm having the following error correcting the folllowing optparse signature:
- | (String params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc) ?{ (*untyped) -> untyped } -> untyped
+ | (*String params, Class | Array[String] | Hash[Symbol, untyped] | Regexp obj, ?String desc) ?{ (*untyped) -> untyped } -> untyped
rbs will throw the following error when parsing:
RBS::ParsingError: stdlib/optparse/0/optparse.rbs:697:33...697:34: Syntax error: optional keyword argument type is expected, token=`(` (pLPAREN)
/Users/tiagocardoso/dev/rbs/lib/rbs/parser_aux.rb:12:in `_parse_signature'
/Users/tiagocardoso/dev/rbs/lib/rbs/parser_aux.rb:12:in `parse_signature'
test/rbs/writer_test.rb:236:in `block in test_smoke'
I think that the parser can't deal with optional rest arguments, when splatting is used.
This is an intended behavior, because optional argument after splat is not supported in Ruby.
The semantics of method argument binding in RBS and Ruby are different. So, it may be possible, once we found a good semantics that works and can be implemented.
Feel free to reopen this issue to continue the discussion.
I'd keep this open, as this is valid ruby code that cannot be typed yet. But it's your call.