Skip to content

Module#attr_setter does not support frozen-string-literal #286

@taichi-ishitani

Description

@taichi-ishitani

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions