diff --git a/src/parser.c b/src/parser.c index be238c759..cf7c9e880 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1120,7 +1120,7 @@ static bool parse_simple(rbs_parser_t *parser, rbs_node_t **type, bool void_allo switch (parser->current_token.type) { case pLPAREN: { rbs_node_t *lparen_type; - CHECK_PARSE(rbs_parse_type(parser, &lparen_type, false, self_allowed, classish_allowed)); + CHECK_PARSE(rbs_parse_type(parser, &lparen_type, void_allowed, self_allowed, classish_allowed)); ADVANCE_ASSERT(parser, pRPAREN); *type = lparen_type; return true; diff --git a/test/rbs/method_type_parsing_test.rb b/test/rbs/method_type_parsing_test.rb index fd04ed718..c6b561faf 100644 --- a/test/rbs/method_type_parsing_test.rb +++ b/test/rbs/method_type_parsing_test.rb @@ -32,6 +32,12 @@ def test_method_type Parser.parse_method_type("(?foo?: Integer, ?bar!: String)->void") end + def test_method_type__void_in_paren + Parser.parse_method_type("() -> (void)").tap do |type| + assert_instance_of Types::Bases::Void, type.type.return_type + end + end + def test_method_param Parser.parse_method_type("(untyped _, top __, Object _2, String _abc_123)->void").yield_self do |type| assert_equal "(untyped _, top __, Object _2, String _abc_123) -> void", type.to_s diff --git a/test/rbs/type_parsing_test.rb b/test/rbs/type_parsing_test.rb index c140442f8..97c5754b9 100644 --- a/test/rbs/type_parsing_test.rb +++ b/test/rbs/type_parsing_test.rb @@ -925,6 +925,11 @@ def test_parse__void__return_types Parser.parse_type("^() { () -> void } -> void").tap do |type| assert_instance_of Types::Proc, type end + + Parser.parse_type("^() -> (void)").tap do |type| + assert_instance_of Types::Proc, type + assert_instance_of Types::Bases::Void, type.type.return_type + end end def test_parse__void__prohibited