tmm1 / ripper-tags

fast, accurate ctags generator for ruby source code using Ripper
MIT License
550 stars 43 forks source link

Fix parse error for delegate statements with dynamic arguments #114

Closed latortuga closed 1 year ago

latortuga commented 1 year ago

I updated to 1.0 today because I saw the announcement in Ruby Weekly last week. I am now getting a NoMethodError where previously there was no error when parsing (on v.0.9.1):

NoMethodError parsing `myfile.rb': undefined method `first' for nil:NilClass

To be clear, I can still use it but this particular construction seems to throw the parser.

I've made a minimal test case that recreates the behavior.

class C
  def object = Object.new

  # these all work
  delegate :thing, to: :object
  delegate :thing=, to: :object
  %i(other).each do |k|
    delegate k, to: :object
    delegate :"#{k}", to: :object
  end

  # does not work!
  %(foo).each do |k|
    delegate k, :"#{k}=", to: :object
  end
end
latortuga commented 1 year ago

I just made the test because I am not sure how to fix this at this point and wanted y'all to know it was happening. I'm not entirely sure if this can be fixed because it seems to be regarding an argument to delegate that is determined dynamically but even if we can't make it function I figured it should not throw an error.

latortuga commented 1 year ago

(btw @mislav thank you for will_paginate ❤️ )

mislav commented 1 year ago

Thank you for reporting!

The ruby 2.2 CI failure is not related to this change: https://github.com/ruby/setup-ruby/issues/496