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 an error when parsing non UTF-8 frozen string #262

Conversation

koic
Copy link
Member

@koic koic commented May 2, 2023

This PR fixes the following FrozenError when parsing non UTF-8 frozen string:

$ cat example.rb
# encoding: ascii-8bit
# frozen_string_literal: true

require 'rubocop-ast'

RuboCop::AST::ProcessedSource.new('true', 3.2)
$ ruby example.rb
/Users/koic/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.28.0/lib/rubocop/ast/processed_source.rb:30:
in `force_encoding': can't modify frozen String: "true" (FrozenError)
from /Users/koic/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.28.0/lib/rubocop/ast/processed_source.rb:30:
in `initialize'
from example.rb:6:in `new'
from example.rb:6:in `<main>'

This PR fixes the following `FrozenError` when parsing non UTF-8 frozen string:

```console
$ cat example.rb
# encoding: ascii-8bit
# frozen_string_literal: true

require 'rubocop-ast'

RuboCop::AST::ProcessedSource.new('true', 3.2)
```

```console
$ ruby example.rb
/Users/koic/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.28.0/lib/rubocop/ast/processed_source.rb:30:
in `force_encoding': can't modify frozen String: "true" (FrozenError)
from /Users/koic/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.28.0/lib/rubocop/ast/processed_source.rb:30:
in `initialize'
from example.rb:6:in `new'
from example.rb:6:in `<main>'
```
@koic
Copy link
Member Author

koic commented May 2, 2023

The master brach of RuboCop has been dropped Ruby 2.6 runtime support. So CI / Main Gem Specs | RuboCop: master | 2.6 (pull_request) build failures will be dismissed by #263.

@marcandre marcandre merged commit 934fc2c into rubocop:master May 2, 2023
17 of 19 checks passed
@marcandre
Copy link
Contributor

Cool, thanks

@koic koic deleted the fix_an_error_when_parsing_non_utf_8_frozen_string branch May 2, 2023 04:25
@koic
Copy link
Member Author

koic commented May 2, 2023

Thanks for the quick release!

koic added a commit to koic/rubocop that referenced this pull request Jul 24, 2023
This PR makes aware of `Style/RedundantArgument` aware of `exit` and `exit!`.
It require RuboCop AST 1.28.1+ that includes rubocop/rubocop-ast#262.
bbatsov pushed a commit to rubocop/rubocop that referenced this pull request Jul 24, 2023
This PR makes aware of `Style/RedundantArgument` aware of `exit` and `exit!`.
It require RuboCop AST 1.28.1+ that includes rubocop/rubocop-ast#262.
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

Successfully merging this pull request may close these issues.

None yet

2 participants