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 issue with 'from' clause and frozen_string_literal magic comment #72

Merged
merged 1 commit into from
Jul 6, 2020
Merged

Fix issue with 'from' clause and frozen_string_literal magic comment #72

merged 1 commit into from
Jul 6, 2020

Conversation

khataev
Copy link

@khataev khataev commented Jul 4, 2020

I suggest a fix for situation when adding magic comment frozen_string_literal to file with ROXML definition

  # frozen_string_literal: true

  class Book
    include ROXML

    xml_reader :isbn, from: '@isbn'
  end

having this, you'll get the following error during serialization:

FrozenError: can't modify frozen String: "@isbn"
from /Users/khataev/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/roxml-4.1.0/lib/roxml/definition.rb:63:in `sub!'

fix is simple, replacing bang version of sub! with safe version

@Empact
Copy link
Owner

Empact commented Jul 5, 2020

This looks good, would you add a test for this?

@khataev
Copy link
Author

khataev commented Jul 5, 2020

Shure )

@khataev
Copy link
Author

khataev commented Jul 5, 2020

Done

@Empact Empact merged commit d6675eb into Empact:master Jul 6, 2020
@Empact
Copy link
Owner

Empact commented Jul 6, 2020

Thanks 👍

@khataev khataev deleted the frozen-string-literal-fix branch July 6, 2020 07:15
@khataev
Copy link
Author

khataev commented Jul 6, 2020

@Empact when will we get updated gem with current fix?

@Empact
Copy link
Owner

Empact commented Jul 6, 2020

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.

2 participants