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

Commits on May 2, 2023

  1. Fix an error when parsing non UTF-8 frozen string

    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 committed May 2, 2023
    Configuration menu
    Copy the full SHA
    74e6b98 View commit details
    Browse the repository at this point in the history