Return a plain Token for Prism.lex etc. - #4206
Open
Earlopain wants to merge 1 commit into
Open
Conversation
Earlopain
force-pushed
the
lex-state-internal
branch
from
August 17, 2026 20:28
60b981a to
59038f8
Compare
Earlopain
commented
Aug 17, 2026
| @@ -846,14 +846,7 @@ parse_lex_token(pm_parser_t *parser, pm_token_t *token, void *data) { | |||
| parse_lex_data_t *parse_lex_data = (parse_lex_data_t *) data; | |||
|
|
|||
| VALUE value = pm_token_new(parser, token, parse_lex_data->encoding, parse_lex_data->source, parse_lex_data->freeze); | |||
Collaborator
Author
There was a problem hiding this comment.
This already freezes the returned token if applicable, not necessary here again
Instead of a 2-element array. Nobody should care about the state, and nobody seems to. A code search on Github shows that it only gets discarded (like via `value.map(&:first)`, or similar things. But because our own ripper translator still needs it for compatibility, we have to keep it around in some way. I played around with `Prism.lex_internal` that keeps the same return value but that duplicates much logic like serialization/deserialization. This achieves the same thing and is much smaller in scope.
Earlopain
force-pushed
the
lex-state-internal
branch
from
August 17, 2026 20:36
59038f8 to
738759e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instead of a 2-element array. Nobody should care about the state, and nobody seems to. A code search on Github shows that it only gets discarded (like via
value.map(&:first), or similar things.But because our own ripper translator still needs it for compatibility, we have to keep it around in some way. I played around with something like
Prism.lex_internalthat keeps the same return value but that duplicates much logic like serialization/deserialization.This achieves the same thing and is much smaller in scope.