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

to_s failing for unnamed struct bit-field members #12

Open
undurgongor opened this issue Aug 7, 2014 · 0 comments
Open

to_s failing for unnamed struct bit-field members #12

undurgongor opened this issue Aug 7, 2014 · 0 comments

Comments

@undurgongor
Copy link

require 'cast'
s = <<-EOS
  struct foo {
       unsigned :4;
  };

EOS
ast = C.parse(s)
ast.to_s

yields

TypeError: can't dup NilClass
from .../ruby/gems/2.0.0/gems/cast-0.2.1/lib/cast/to_s.rb:48:in `dup'
...

proposed patch:

--- to_s.rb.orig        2037-08-09 14:29:46.000000000 +0200
+++ to_s.rb     2014-08-07 11:49:11.705897200 +0200
@@ -45,7 +45,7 @@
   end
   class Declarator
     def to_s
-      (indirect_type ? indirect_type.to_s(name) : name.dup) <<
+      (indirect_type ? indirect_type.to_s(name) : (name || '').dup) <<
         (init ? " = #{init}" : '') <<
         (num_bits ? " : #{num_bits}" : '')
     end

And a big "Thank you!" for cast.

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

No branches or pull requests

1 participant