Skip to content

Commit

Permalink
Support Parser::Ruby31
Browse files Browse the repository at this point in the history
Parser gem has been started development for Ruby 3.1 (edge Ruby).
whitequark/parser#792

This PR supports `Parser::Ruby31`, the early adapters will be able to try
edge Ruby with RuboCop.

And this PR update to require Parser 3.0.1.1 or higher, which contains
`Parser::Ruby31`.
https://github.com/whitequark/parser/blob/master/CHANGELOG.md#v3011-2021-05-02
  • Loading branch information
koic authored and marcandre committed May 2, 2021
1 parent 76b1419 commit e4e461d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/new_support_ruby_3_1_parser.md
@@ -0,0 +1 @@
* [#182](https://github.com/rubocop-hq/rubocop-ast/pull/182): Support `Parser::Ruby31` for Ruby 3.1 parser (experimental). ([@koic][])
3 changes: 3 additions & 0 deletions lib/rubocop/ast/processed_source.rb
Expand Up @@ -236,6 +236,9 @@ def parser_class(ruby_version)
when 2.8, 3.0
require 'parser/ruby30'
Parser::Ruby30
when 3.1
require 'parser/ruby31'
Parser::Ruby31
else
raise ArgumentError,
"RuboCop found unknown Ruby version: #{ruby_version.inspect}"
Expand Down
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -43,6 +43,10 @@
let(:ruby_version) { 3.0 }
end

RSpec.shared_context 'ruby 3.1', :ruby31 do
let(:ruby_version) { 3.1 }
end

# ...
module DefaultRubyVersion
extend RSpec::SharedContext
Expand Down

0 comments on commit e4e461d

Please sign in to comment.