Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions test/rbs/method_type_parsing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/rbs/type_parsing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down