pocke / rbs_rails

Apache License 2.0
285 stars 33 forks source link

Should quote var name #178

Closed ksss closed 3 years ago

ksss commented 3 years ago

Fix the problem that rake fails when using rbs reserved words (e.g. type) in variable names. The following is the log of the failure.

rake aborted!
RBS::Parser::SyntaxError: parse error on value: #<RBS::Parser::LocatedValue:0x0000aaaaea01def8 @location=#<RBS::Location:19500 @buffer=, @pos=6514...6518, source='type', start_line=142, start_column=27>, @value=:type> (kTYPE)
parser.y:1757:in `on_error'
(eval):3:in `_racc_do_parse_c'
(eval):3:in `do_parse'
parser.y:1458:in `parse_signature'
/api/vendor/bundle/ruby/3.0.0/gems/rbs_rails-0.8.2/lib/rbs_rails/util.rb:19:in `format_rbs'
/api/vendor/bundle/ruby/3.0.0/gems/rbs_rails-0.8.2/lib/rbs_rails/active_record.rb:25:in `generate'
/api/vendor/bundle/ruby/3.0.0/gems/rbs_rails-0.8.2/lib/rbs_rails/active_record.rb:11:in `class_to_rbs'
/api/vendor/bundle/ruby/3.0.0/gems/rbs_rails-0.8.2/lib/rbs_rails/rake_task.rb:45:in `block (2 levels) in def_generate_rbs_for_models'
/api/vendor/bundle/ruby/3.0.0/gems/rbs_rails-0.8.2/lib/rbs_rails/rake_task.rb:38:in `each'
/api/vendor/bundle/ruby/3.0.0/gems/rbs_rails-0.8.2/lib/rbs_rails/rake_task.rb:38:in `block in def_generate_rbs_for_models'
/api/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/api/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/api/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/fork_tracker.rb:10:in `block in fork'
/api/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/fork_tracker.rb:10:in `block in fork'
/api/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/fork_tracker.rb:8:in `fork'
/api/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/fork_tracker.rb:8:in `fork'
/api/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/fork_tracker.rb:26:in `fork'
/api/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/fork_tracker.rb:8:in `fork'
/api/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/fork_tracker.rb:26:in `fork'
<internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
-e:1:in `<main>'
Tasks: TOP => rbs_rails:generate_rbs_for_models
(See full trace by running task with --trace)
ksss commented 3 years ago

Here seems to be the reason why the ruby-head CI is failing https://github.com/rails/globalid/pull/132

ksss commented 3 years ago

Maybe fixed.