From f279d41847e07949ca7ad3f2d3d5cbe9fa3aabf5 Mon Sep 17 00:00:00 2001 From: manga_osyo Date: Mon, 6 Dec 2021 10:04:12 +0900 Subject: Fix warning in `Lexer::Elem#[]` Changed to use `#pos` `#event` `#tok` `#state` since using Lexer::Elem#[0~4] now gives a warning. see: https://github.com/ruby/ruby/commit/8944009be7418614ce7d4077807ac2b60d4d5d85 https://github.com/ruby/reline/commit/9adbb9af32 --- lib/irb/ruby-lex.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/irb') diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index f2069a2b5f..29862f5507 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -752,16 +752,16 @@ class RubyLex end i += 1 end - start_token.last.nil? ? '' : start_token.last + start_token.last.nil? ? nil : start_token.last end def process_literal_type(tokens = @tokens) start_token = check_string_literal(tokens) return nil if start_token == "" - case start_token.event + case start_token&.event when :on_tstring_beg - case start_token.tok + case start_token&.tok when ?" then ?" when /^%.$/ then ?" when /^%Q.$/ then ?" @@ -776,7 +776,7 @@ class RubyLex when :on_qsymbols_beg then ?] when :on_symbols_beg then ?] when :on_heredoc_beg - start_token.tok =~ /<<[-~]?(['"`])[_a-zA-Z0-9]+\1/ + start_token&.tok =~ /<<[-~]?(['"`])[_a-zA-Z0-9]+\1/ case $1 when ?" then ?" when ?' then ?' -- cgit v1.2.3