@@ -1551,7 +1551,7 @@ static bool parser_pop_typevar_table(rbs_parser_t *parser) {
15511551 method_type ::= {} type_params <function>
15521552 */
15531553// TODO: Should this be NODISCARD?
1554- bool rbs_parse_method_type (rbs_parser_t * parser , rbs_method_type_t * * method_type ) {
1554+ bool rbs_parse_method_type (rbs_parser_t * parser , rbs_method_type_t * * method_type , bool require_eof ) {
15551555 rbs_parser_push_typevar_table (parser , false);
15561556
15571557 rbs_range_t rg ;
@@ -1567,10 +1567,18 @@ bool rbs_parse_method_type(rbs_parser_t *parser, rbs_method_type_t **method_type
15671567 parse_function_result * result = rbs_allocator_alloc (ALLOCATOR (), parse_function_result );
15681568 CHECK_PARSE (parse_function (parser , false, & result , true));
15691569
1570+ CHECK_PARSE (parser_pop_typevar_table (parser ));
1571+
15701572 rg .end = parser -> current_token .range .end ;
15711573 type_range .end = rg .end ;
15721574
1573- CHECK_PARSE (parser_pop_typevar_table (parser ));
1575+ if (require_eof ) {
1576+ rbs_parser_advance (parser );
1577+ if (parser -> current_token .type != pEOF ) {
1578+ rbs_parser_set_error (parser , parser -> current_token , true, "expected a token `%s`" , rbs_token_type_str (pEOF ));
1579+ return false;
1580+ }
1581+ }
15741582
15751583 rbs_location_t * loc = rbs_location_new (ALLOCATOR (), rg );
15761584 rbs_loc_alloc_children (ALLOCATOR (), loc , 2 );
@@ -1979,7 +1987,7 @@ static bool parse_member_def(rbs_parser_t *parser, bool instance_only, bool acce
19791987 case pLBRACKET :
19801988 case pQUESTION : {
19811989 rbs_method_type_t * method_type = NULL ;
1982- CHECK_PARSE (rbs_parse_method_type (parser , & method_type ));
1990+ CHECK_PARSE (rbs_parse_method_type (parser , & method_type , false ));
19831991
19841992 overload_range .end = parser -> current_token .range .end ;
19851993 rbs_location_t * loc = rbs_location_new (ALLOCATOR (), overload_range );
@@ -3607,7 +3615,7 @@ static bool parse_method_overload(rbs_parser_t *parser, rbs_node_list_t *annotat
36073615 return false;
36083616 }
36093617
3610- return rbs_parse_method_type (parser , method_type );
3618+ return rbs_parse_method_type (parser , method_type , false );
36113619}
36123620
36133621/*
0 commit comments