1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

ext/ripper/lib/ripper/lexer.rb: Do not deprecate Ripper::Lexer::State#[]

The old code of IRB still uses this method. The warning is noisy on
rails console.
In principle, Ruby 3.1 deprecates nothing, so let's avoid the
deprecation for the while.
I think It is not so hard to continue to maintain it as it is a trivial
shim.

https://github.com/ruby/ruby/pull/5093
This commit is contained in:
Yusuke Endoh 2021-12-06 11:35:54 +09:00
parent 3021c3cedc
commit 17e7219679
Notes: git 2021-12-09 00:30:46 +09:00

View file

@ -64,12 +64,12 @@ class Ripper
def [](index) def [](index)
case index case index
when 0 when 0, :to_int
warn "Calling `Lexer::State#[0]` is deprecated, please use `Lexer::State#to_int` instead"
@to_int @to_int
when 1 when 1, :to_s
warn "Calling `Lexer::State#[1]` is deprecated, please use `Lexer::State#to_s` instead"
@event @event
else
nil
end end
end end
@ -97,21 +97,18 @@ class Ripper
def [](index) def [](index)
case index case index
when 0 when 0, :pos
warn "Calling `Lexer::Elem#[0]` is deprecated, please use `Lexer::Elem#pos` instead"
@pos @pos
when 1 when 1, :event
warn "Calling `Lexer::Elem#[1]` is deprecated, please use `Lexer::Elem#event` instead"
@event @event
when 2 when 2, :tok
warn "Calling `Lexer::Elem#[2]` is deprecated, please use `Lexer::Elem#tok` instead"
@tok @tok
when 3 when 3, :state
warn "Calling `Lexer::Elem#[3]` is deprecated, please use `Lexer::Elem#state` instead"
@state @state
when 4 when 4, :message
warn "Calling `Lexer::Elem#[4]` is deprecated, please use `Lexer::Elem#message` instead"
@message @message
else
nil
end end
end end