Skip to content

Conversation

@allcre
Copy link

@allcre allcre commented Dec 16, 2025

Motivation

Test plan

See included automated tests.

Copy link
Author

allcre commented Dec 16, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@allcre allcre force-pushed the ac-add_signaturetranslatorprism_and_typeparamstoparsernodesprism branch from 376f9e6 to 3a61f26 Compare December 16, 2025 22:09
@allcre allcre force-pushed the ac-add_methodtypetoparsernodeprism_for_rbs_method_signature_translation branch from 8914ab9 to 77219b7 Compare December 16, 2025 22:09
@allcre allcre marked this pull request as ready for review December 16, 2025 22:18
@allcre allcre force-pushed the ac-add_signaturetranslatorprism_and_typeparamstoparsernodesprism branch from 3a61f26 to ebf3230 Compare December 16, 2025 22:22
@allcre allcre force-pushed the ac-add_methodtypetoparsernodeprism_for_rbs_method_signature_translation branch from 77219b7 to 005a338 Compare December 16, 2025 22:22
rbs_string_t rbsString = makeRBSString(assertion.string);
const rbs_encoding_t *encoding = RBS_ENCODING_UTF_8_ENTRY;

Parser parser(rbsString, encoding);

Choose a reason for hiding this comment

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

Uniform initialization

Suggested change
Parser parser(rbsString, encoding);
Parser parser{rbsString, encoding};

Choose a reason for hiding this comment

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

Likewise for the cases below

Comment on lines 56 to 59
rbs_string_t rbsString = makeRBSString(declaration.string);
const rbs_encoding_t *encoding = RBS_ENCODING_UTF_8_ENTRY;

Parser parser(rbsString, encoding);

Choose a reason for hiding this comment

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

This repeats 5 times, can you extract a private helper?

auto nameStr = parser.resolveConstant(rbsTypeParam->name);
auto nameConstant = ctx.state.enterNameConstant(nameStr);

vector<pm_node_t *> args;

Choose a reason for hiding this comment

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

This will only have 0 or 1 elements. We can skip this heap allocation if we use an inlined vector on the stack:

Suggested change
vector<pm_node_t *> args;
absl::InlinedVector<pm_node_t *, 1> args;

pm_node_t *block = nullptr;
if (defaultType || upperBound || lowerBound) {
auto typeTranslator = TypeToParserNodePrism(ctx, {}, parser, prismParser);
vector<pm_node_t *> pairs;

Choose a reason for hiding this comment

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

Similar

Suggested change
vector<pm_node_t *> pairs;
absl::InlinedVector<pm_node_t *, 3> pairs;


private:
core::MutableContext ctx;
parser::Prism::Parser *parser; // For Prism node creation

Choose a reason for hiding this comment

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

Unused?

Copy link
Author

Choose a reason for hiding this comment

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

Passed to a few translators:

    auto methodTypeToParserNodePrism = MethodTypeToParserNodePrism(ctx, move(parser), *this->parser);

Choose a reason for hiding this comment

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

Those are different, there's Parser parser local variables that shadow this->parser

Copy link
Author

Choose a reason for hiding this comment

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

So if I'm understanding correctly the 2nd arg in the line of code above is the local variable parser but the 3rd arg is the member variable? So it is being used? I can also rename all the local variables to rbsParser to avoid this confusion.

Choose a reason for hiding this comment

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

Yeah, in the context where we have both, it would be more clear to give one or both of them prefixes. Relying on variable shadowing to draw the distinction is pretty non-obvious

@allcre allcre force-pushed the ac-add_methodtypetoparsernodeprism_for_rbs_method_signature_translation branch from 005a338 to 4536485 Compare December 19, 2025 19:35
@allcre allcre force-pushed the ac-add_signaturetranslatorprism_and_typeparamstoparsernodesprism branch 3 times, most recently from 284ba10 to 820e412 Compare December 22, 2025 19:13
@allcre allcre force-pushed the ac-add_methodtypetoparsernodeprism_for_rbs_method_signature_translation branch from 4536485 to 388f9ab Compare December 23, 2025 22:04
@allcre allcre force-pushed the ac-add_signaturetranslatorprism_and_typeparamstoparsernodesprism branch from 82b09ef to 58b03c9 Compare December 23, 2025 22:04
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.

2 participants