summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEarlopain <14981592+Earlopain@users.noreply.github.com>2026-01-17 20:28:01 +0100
committergit <svn-admin@ruby-lang.org>2026-01-18 14:07:06 +0000
commitd1dc4bdb2fe7f16e6da78c0930353e4a5031465a (patch)
tree9a7916a236750e2117f30bca6f6f3b41f4ba20fa /lib
parent00a3b71eaf6f1a69f319de4b50e79ab1765d0cd8 (diff)
[ruby/prism] Fix ripper translator for `__END__`
https://github.com/ruby/prism/commit/2792ac78ca
Diffstat (limited to 'lib')
-rw-r--r--lib/prism/lex_compat.rb13
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/prism/lex_compat.rb b/lib/prism/lex_compat.rb
index 46f6130357..b7c54178ac 100644
--- a/lib/prism/lex_compat.rb
+++ b/lib/prism/lex_compat.rb
@@ -225,14 +225,6 @@ module Prism
end
end
- # Ripper doesn't include the rest of the token in the event, so we need to
- # trim it down to just the content on the first line when comparing.
- class EndContentToken < Token
- def ==(other) # :nodoc:
- [self[0], self[1], self[2][0..self[2].index("\n")], self[3]] == other
- end
- end
-
# Tokens where state should be ignored
# used for :on_comment, :on_heredoc_end, :on_embexpr_end
class IgnoreStateToken < Token
@@ -680,7 +672,10 @@ module Prism
token =
case event
when :on___end__
- EndContentToken.new([[lineno, column], event, value, lex_state])
+ # Ripper doesn't include the rest of the token in the event, so we need to
+ # trim it down to just the content on the first line.
+ value = value[0..value.index("\n")]
+ Token.new([[lineno, column], event, value, lex_state])
when :on_comment
IgnoreStateToken.new([[lineno, column], event, value, lex_state])
when :on_heredoc_end