ruby-gettext / gettext

Gettext gem is a pure Ruby Localization(L10n) library and tool which is modeled after the GNU gettext package.
https://ruby-gettext.github.io/
69 stars 28 forks source link

Error when parsing %W(text) #72

Closed MichaelHoste closed 4 years ago

MichaelHoste commented 4 years ago

This seems related to #71

When parsing a file that looks like this:

class Example
  def test
    %W(text)
  end
end

The parser breaks with this error:

NoMethodError: undefined method `<<' for nil:NilClass
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/parser/ruby.rb:157:in `process_on_tstring_content'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/parser/ruby.rb:278:in `block in on_default'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/parser/ruby.rb:293:in `trace'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/parser/ruby.rb:275:in `on_default'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/2.5.0/ripper/filter.rb:66:in `block in parse'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/2.5.0/ripper/filter.rb:61:in `each'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/2.5.0/ripper/filter.rb:61:in `parse'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/parser/ruby.rb:430:in `parse_source'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/parser/ruby.rb:412:in `parse'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/parser/ruby.rb:329:in `parse'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/xgettext.rb:365:in `block in parse_path'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/xgettext.rb:360:in `each'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/xgettext.rb:360:in `parse_path'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/xgettext.rb:168:in `block in parse'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/xgettext.rb:166:in `each'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/xgettext.rb:166:in `parse'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/xgettext.rb:217:in `generate_pot'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/xgettext.rb:151:in `run'
/usr/local/var/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/gettext-3.3.3/lib/gettext/tools/xgettext.rb:34:in `run'

Using %w instead of %W fixes the issue.

(Tested on GetText 3.3.2 and 3.3.3 with ruby 2.5 and 2.7)

kou commented 4 years ago

Thanks for your report. I've fixed this.

MichaelHoste commented 4 years ago

Thanks @kou !

You are always fixing bugs really quickly, it's greatly appreciated!