facets icon indicating copy to clipboard operation
facets copied to clipboard

Module#attr_setter does not support frozen-string-literal

Open taichi-ishitani opened this issue 5 years ago • 0 comments

I got the "can't modify frozen String" error when I use the --enable-frozen-string-literal Ruby option. It is because that Module#attr_setter method does not support frozen-string-literal.

You can see the same error by running commands below

$ export RUBYOPT='--enable-frozen-string-literal'
$ ruby-test test/core/module/test_attr_setter.rb

Then, you will see the error message below

    can't modify frozen String
    C:/Users/ishitani/workspace/facets/lib/core/facets/module/attr_setter.rb:24
    22     code, made = '', []
    23     args.each do |a|
 => 24       code << %{
    25         def #{a}(*args)
    26           args.size > 0 ? ( @#{a}=args[0] ; self ) : @#{a}
    C:/Users/ishitani/workspace/facets/lib/core/facets/module/attr_setter.rb:24
    C:/Users/ishitani/workspace/facets/lib/core/facets/module/attr_setter.rb:23
    test/core/module/test_attr_setter.rb:9
    test/core/module/test_attr_setter.rb:8
    C:/Ruby/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rubytest-cli-0.2.0/lib/rubytest-cli.rb:48
    C:/Ruby/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rubytest-cli-0.2.0/lib/rubytest-cli.rb:18
    C:/Ruby/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rubytest-cli-0.2.0/bin/ruby-test:4
    C:/Ruby/Ruby25-x64/bin/ruby-test:23

taichi-ishitani avatar Feb 27 '19 05:02 taichi-ishitani