Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Racc::ParseError so Pattern Matching is supported #145

Open
bkuhlmann opened this issue Dec 12, 2020 · 2 comments
Open

Fix Racc::ParseError so Pattern Matching is supported #145

bkuhlmann opened this issue Dec 12, 2020 · 2 comments

Comments

@bkuhlmann
Copy link

bkuhlmann commented Dec 12, 2020

Overview

When using Flog on a project that uses Ruby Pattern Matching, I get the following error:

 bkuhlmann@vilya  rubysmith  alchemists.io  ⑂ release +    flog
ERROR: parsing ruby file ./lib/rubysmith/cli/shell.rb
ERROR! Aborting. You may want to run with --continue.
Traceback (most recent call last):
	23: from /Users/bkuhlmann/.gem/ruby/2.7.2/bin/flog:23:in `<main>'
	22: from /Users/bkuhlmann/.gem/ruby/2.7.2/bin/flog:23:in `load'
	21: from /Users/bkuhlmann/.gem/ruby/2.7.2/gems/flog-4.6.4/bin/flog:5:in `<top (required)>'
	20: from /Users/bkuhlmann/.gem/ruby/2.7.2/gems/flog-4.6.4/lib/flog_cli.rb:28:in `run'
	19: from /Users/bkuhlmann/.gem/ruby/2.7.2/gems/flog-4.6.4/lib/flog_cli.rb:162:in `flog'
	18: from /Users/bkuhlmann/.gem/ruby/2.7.2/gems/flog-4.6.4/lib/flog.rb:177:in `flog'
	17: from /Users/bkuhlmann/.gem/ruby/2.7.2/gems/flog-4.6.4/lib/flog.rb:177:in `each'
	16: from /Users/bkuhlmann/.gem/ruby/2.7.2/gems/flog-4.6.4/lib/flog.rb:182:in `block in flog'
	15: from /Users/bkuhlmann/.gem/ruby/2.7.2/gems/flog-4.6.4/lib/flog.rb:194:in `flog_ruby'
	14: from /Users/bkuhlmann/.gem/ruby/2.7.2/gems/flog-4.6.4/lib/flog.rb:224:in `flog_ruby!'
	13: from /Users/bkuhlmann/.gem/ruby/2.7.2/gems/ruby_parser-3.15.0/lib/ruby_parser.rb:33:in `process'
	12: from /Users/bkuhlmann/.gem/ruby/2.7.2/gems/ruby_parser-3.15.0/lib/ruby_parser.rb:33:in `each'
	11: from /Users/bkuhlmann/.gem/ruby/2.7.2/gems/ruby_parser-3.15.0/lib/ruby_parser.rb:36:in `block in process'
	10: from /Users/bkuhlmann/.gem/ruby/2.7.2/gems/ruby_parser-3.15.0/lib/ruby_parser_extras.rb:1317:in `process'
	 9: from /Users/bkuhlmann/.rubies/ruby-2.7.2/lib/ruby/2.7.0/timeout.rb:110:in `timeout'
	 8: from /Users/bkuhlmann/.rubies/ruby-2.7.2/lib/ruby/2.7.0/timeout.rb:33:in `catch'
	 7: from /Users/bkuhlmann/.rubies/ruby-2.7.2/lib/ruby/2.7.0/timeout.rb:33:in `catch'
	 6: from /Users/bkuhlmann/.rubies/ruby-2.7.2/lib/ruby/2.7.0/timeout.rb:33:in `block in catch'
	 5: from /Users/bkuhlmann/.rubies/ruby-2.7.2/lib/ruby/2.7.0/timeout.rb:95:in `block in timeout'
	 4: from /Users/bkuhlmann/.gem/ruby/2.7.2/gems/ruby_parser-3.15.0/lib/ruby_parser_extras.rb:1329:in `block in process'
	 3: from (eval):3:in `do_parse'
	 2: from (eval):3:in `_racc_do_parse_c'
	 1: from /Users/bkuhlmann/.gem/ruby/2.7.2/gems/ruby_parser-3.15.0/lib/ruby_parser_extras.rb:1304:in `on_error'
/Users/bkuhlmann/.gem/ruby/2.7.2/gems/racc-1.5.1/lib/racc/parser.rb:538:in `on_error': ./lib/rubysmith/cli/shell.rb:27 :: parse error on value ["in", 27] (kIN) (Racc::ParseError)

Steps to Recreate

To recreate, I'm using Flog to illustrate since Flog has Racc as a dependency. Save the following to snippet.rb and run as ruby snippet.rb to see the issue:

# frozen_string_literal: true

require "bundler/inline"

gemfile true do
  source "https://rubygems.org"
  gem "flog", "~> 4.6"
end

collection = {
  a: 1,
  b: 2
}

case collection
  in a: value then puts value
  in b: value then puts value
end

Desired Behavior

Would like to see Racc handle pattern matching without error.

Environment

ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
@bkuhlmann bkuhlmann changed the title Fix Racc::ParseError so Ruby Pattern Matching is supported Fix Racc::ParseError so Pattern Matching is supported Dec 12, 2020
@zenspider
Copy link
Collaborator

It's late... but I'm confused... isn't this a problem with flog (or, ruby_parser)?

@bkuhlmann
Copy link
Author

Hey Ryan. 👋 Hmm, perhaps you are right? Would you like me to close this down and file this issue in the Ruby Parser project instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants