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

Unfreeze string literals for ParseNode#inspect #1016

merged 1 commit into from
Aug 6, 2019


Copy link

@jalyna jalyna commented Aug 6, 2019

Since newrelic is using the #inspect method on ParseNode the ruby code crashes due to frozen strings in inspect, which are recursively called with gsub! causing this error:

Screen Shot 2019-08-06 at 10 54 08

I added a regression test that fails with the current code.

@jalyna jalyna force-pushed the fix-frozen-string-literals-on-inspect branch from 1ea26c4 to bc88181 Compare August 6, 2019 09:41
Copy link

amatsuda commented Aug 6, 2019

@jalyna Thank you for the patch!
I understand that we need the first children.each_with_object(''.dup) modification, but I don't see why we need the second .dup call at the end of that line.

Copy link

jalyna commented Aug 6, 2019

@amatsuda this is a really good question! the second .dup is still needed because %Q[] creates a frozen string literal (still). The test will fail if it gets removed.

# frozen_string_literal: true

puts %Q[hello world].frozen?

prints true.

We could also use something else here 🤔

Copy link

amatsuda commented Aug 6, 2019

@jalyna Ah! I just got what you meant by "which are recursively called". Thank you for a clear explanation (and I'm sorry that I wasn't carefully reading it...)!

@amatsuda amatsuda merged commit 4dbb180 into haml:master Aug 6, 2019
Copy link

amatsuda commented Aug 6, 2019

@jalyna Just published version 5.1.2 gem with this patch. Thanks!

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Mar 24, 2020
Update ruby-haml to 5.1.2.
pkgsrc change: add "USE_LANGUAGES=	# none".

## 5.1.2

Released on August 6, 2019

* Fix crash in some environments such as New Relic by unfreezing string literals for ParseNode#inspect. [#1016](haml/haml#1016) (thanks [Jalyna](

## 5.1.1

Released on May 25, 2019

* Fix NameError bug for that happens on ruby 2.6.1-2.6.3 + haml 5.1.0 + rails 4.2.x + erubi. (Akira Matsuda)

## 5.1.0

Released on May 16, 2019

* Rails 6 support [#1008](haml/haml#1008) (thanks [Seb Jacobs](
* Add `escape_filter_interpolations` option for backwards compatibility with haml 4 defaults [#984](haml/haml#984) (thanks [Will Jordan](
* Fix error on empty :javascript and :css filter blocks [#986](haml/haml#986) (thanks [Will Jordan](
* Respect changes in Haml::Options.defaults in `Haml::TempleEngine` options (Takashi Kokubun)
* Un-freeze TempleEngine precompiled string literals [#983](haml/haml#983) (thanks [Will Jordan](
* Various performance/memory improvements [#965](haml/haml#965), [#966](haml/haml#966), [#963](haml/haml#963) (thanks [Dillon Welch](
* Enable `frozen_string_literal` magic comment for all .rb files [#967](haml/haml#967) (thanks [Dillon Welch](
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants