Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid translating implicit rest nodes in parameters #408

Closed

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Feb 12, 2025

Motivation

Similar to the case in array pattern translation, Sorbet's parser doesn't care about the implicit rest node in parameters either. So the translator should skip its translation.

Addressed the issue mentioned in https://github.com/sorbet/sorbet/pull/8485/files#r1943210573

Test plan

See included automated tests.

if (paramsNode->rest != nullptr)
params.emplace_back(translate(paramsNode->rest));
auto prismRestNode = paramsNode->rest;
// Implicit rest node in parameters don't need to be translated

Choose a reason for hiding this comment

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

Could you please elaborate on the "why"? What was the behaviour before?

Copy link
Member Author

Choose a reason for hiding this comment

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

Previously it simply entered the unreachable function and crash. And Sorbet parser's parse tree doesn't have a corresponding node for it. So I'm not sure how to expand the comment more 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Or do you think I should update it to be can NOT be translated?

Copy link

@amomchilov amomchilov Feb 12, 2025

Choose a reason for hiding this comment

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

Ah I see. Yes "cannot" fit better than "don't need to be" (which implies "can be, but isn't")

Playing around with this, it seems that handles it incorrectly. Found this bug report: sorbet#6407

So I'd suggest explaining that it's a known limitation:

Suggested change
// Implicit rest node in parameters don't need to be translated
// Known limitation: Sorbet doesn't handle implicit rest nodes for restructuring arguments to blocks.
// https://github.com/sorbet/sorbet/issues/6407

@st0012
Copy link
Member Author

st0012 commented Feb 13, 2025

Closing in favor of #409

@st0012 st0012 closed this Feb 13, 2025
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