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

Fix FrozenError on Ripper.slice #1837

Closed
wants to merge 1 commit into from
Closed

Conversation

pocke
Copy link
Member

@pocke pocke commented Mar 13, 2018

Currently Ripper.slice raises a FrozenError

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 /path2/to/test.rb:2:in `<main>'

This patch will fix the problem.

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.
@matzbot matzbot closed this in 67bb959 Mar 13, 2018
@pocke pocke deleted the ripper-frozen-error branch March 13, 2018 14:57
matzbot pushed a commit that referenced this pull request Mar 30, 2020
	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@pocke.me>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@67871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant