@@ -1452,7 +1452,7 @@ static bool parser_pop_typevar_table(rbs_parser_t *parser) {
14521452 method_type ::= {} type_params <function>
14531453 */
14541454// TODO: Should this be NODISCARD?
1455- bool rbs_parse_method_type (rbs_parser_t * parser , rbs_method_type_t * * method_type ) {
1455+ bool rbs_parse_method_type (rbs_parser_t * parser , rbs_method_type_t * * method_type , bool require_eof ) {
14561456 rbs_parser_push_typevar_table (parser , false);
14571457
14581458 rbs_range_t rg ;
@@ -1468,10 +1468,18 @@ bool rbs_parse_method_type(rbs_parser_t *parser, rbs_method_type_t **method_type
14681468 parse_function_result * result = rbs_allocator_alloc (ALLOCATOR (), parse_function_result );
14691469 CHECK_PARSE (parse_function (parser , false, & result ));
14701470
1471+ CHECK_PARSE (parser_pop_typevar_table (parser ));
1472+
14711473 rg .end = parser -> current_token .range .end ;
14721474 type_range .end = rg .end ;
14731475
1474- CHECK_PARSE (parser_pop_typevar_table (parser ));
1476+ if (require_eof ) {
1477+ rbs_parser_advance (parser );
1478+ if (parser -> current_token .type != pEOF ) {
1479+ rbs_parser_set_error (parser , parser -> current_token , true, "expected a token `%s`" , rbs_token_type_str (pEOF ));
1480+ return false;
1481+ }
1482+ }
14751483
14761484 rbs_location_t * loc = rbs_location_new (ALLOCATOR (), rg );
14771485 rbs_loc_alloc_children (ALLOCATOR (), loc , 2 );
@@ -1881,7 +1889,7 @@ static bool parse_member_def(rbs_parser_t *parser, bool instance_only, bool acce
18811889 case pLBRACKET :
18821890 case pQUESTION : {
18831891 rbs_method_type_t * method_type = NULL ;
1884- CHECK_PARSE (rbs_parse_method_type (parser , & method_type ));
1892+ CHECK_PARSE (rbs_parse_method_type (parser , & method_type , false ));
18851893
18861894 overload_range .end = parser -> current_token .range .end ;
18871895 rbs_location_t * loc = rbs_location_new (ALLOCATOR (), overload_range );
0 commit comments