diff options
author | Stan Lo <stan001212@gmail.com> | 2023-04-05 22:40:34 +0100 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-04-05 21:40:40 +0000 |
commit | 2f8e5c80e65a14b3a9298b6cae7ee7fc53890540 (patch) | |
tree | ca1b18b39c4a0d95017361207b635d71a173a639 /lib/irb/ruby-lex.rb | |
parent | 1587494b0b5f64a9976dcf0bd94dfe98123c2c27 (diff) |
[ruby/irb] Drop Ruby 2.6 support
(https://github.com/ruby/irb/pull/555)
* Remove all Ruby 2.6 support
* Drop Ruby 2.6 specific testing conditions
* Only run Ruby 2.7+ on CI
* Bump Ruby requirement to 2.7+
https://github.com/ruby/irb/commit/3f714b616c
Diffstat (limited to 'lib/irb/ruby-lex.rb')
-rw-r--r-- | lib/irb/ruby-lex.rb | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index 9e4a7b28fa..a156f3707a 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -148,19 +148,15 @@ class RubyLex compile_with_errors_suppressed(code, line_no: line_no) do |inner_code, line_no| lexer = Ripper::Lexer.new(inner_code, '-', line_no) - if lexer.respond_to?(:scan) # Ruby 2.7+ - lexer.scan.each_with_object([]) do |t, tokens| - next if t.pos.first == 0 - prev_tk = tokens.last - position_overlapped = prev_tk && t.pos[0] == prev_tk.pos[0] && t.pos[1] < prev_tk.pos[1] + prev_tk.tok.bytesize - if position_overlapped - tokens[-1] = t if ERROR_TOKENS.include?(prev_tk.event) && !ERROR_TOKENS.include?(t.event) - else - tokens << t - end + lexer.scan.each_with_object([]) do |t, tokens| + next if t.pos.first == 0 + prev_tk = tokens.last + position_overlapped = prev_tk && t.pos[0] == prev_tk.pos[0] && t.pos[1] < prev_tk.pos[1] + prev_tk.tok.bytesize + if position_overlapped + tokens[-1] = t if ERROR_TOKENS.include?(prev_tk.event) && !ERROR_TOKENS.include?(t.event) + else + tokens << t end - else - lexer.parse.reject { |it| it.pos.first == 0 }.sort_by(&:pos) end end ensure |