[ruby-cvs:69894] k0kubun:r62743 (trunk): Fix FrozenError on `Ripper.slice`

k0kubun at ruby-lang.org k0kubun at ruby-lang.org
Tue Mar 13 21:56:04 JST 2018


k0kubun	2018-03-13 21:56:04 +0900 (Tue, 13 Mar 2018)

  New Revision: 62743

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62743

  Log:
    Fix FrozenError on `Ripper.slice`
    
    Currently `Ripper.slice` raises a FrozenError
    
    ```ruby
    require 'ripper'
    p Ripper.slice('foo', 'ident')
    ```
    
    ```
    /path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:193:in `concat': can't modify frozen String (FrozenError)
    from /path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:193:in `block in compile'
    from /path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:190:in `scan'
    from /path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:190:in `compile'
    from /path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:169:in `initialize'
    from /path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:151:in `new'
    from /path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:151:in `token_match'
    from /path/to/g/lib/ruby/2.6.0/ripper/lexer.rb:144:in `slice'
    from /tmp/tmp.kb4cnhvum2/test.rb:2:in `<main>'
    ```
    
    This patch will fix the problem.
    
    [Fix GH-1837]
    
    From: Masataka Pocke Kuwabara <kuwabara at pocke.me>

  Modified files:
    trunk/ext/ripper/lib/ripper/lexer.rb


More information about the ruby-cvs mailing list