Skip to content

Return a plain Token for Prism.lex etc. - #4206

Merged
kddnewton merged 1 commit into
ruby:mainfrom
Earlopain:lex-state-internal
Aug 18, 2026
Merged

Return a plain Token for Prism.lex etc.#4206
kddnewton merged 1 commit into
ruby:mainfrom
Earlopain:lex-state-internal

Conversation

@Earlopain

@Earlopain Earlopain commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

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_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.

Comment thread ext/prism/extension.c
Comment thread lib/prism/parse_result.rb
Comment thread lib/prism/lex_compat.rb Outdated
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.
@kddnewton
kddnewton merged commit 32455d1 into ruby:main Aug 18, 2026
100 of 101 checks passed
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