Skip to content

Conversation

@soutaro
Copy link
Member

@soutaro soutaro commented Oct 8, 2025

The require_eof: argument in Parser.parse_method_type is handled by the Ruby extension layer, but this PR moves the feature to the C API, enabling other RBS parser clients, like Sorbet, to utilize it as well.

@soutaro soutaro added this to the RBS 4.0 milestone Oct 8, 2025
src/parser.c Outdated
}
}

CHECK_PARSE(parser_pop_typevar_table(parser));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try moving this before the if condition above?

  CHECK_PARSE(parser_pop_typevar_table(parser));

  if (require_eof) {
      rbs_parser_advance(parser);
      if (parser->current_token.type != pEOF) {
          rbs_parser_set_error(parser, parser->current_token, true, "expected a token `%s`", rbs_token_type_str(pEOF));
          return false;
      }
  }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sure when we see pEOF, the typevar table is still popped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... Confirmed the typevar_table is allocated through the allocator. So, this should not actually cause a leak. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants