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

FrozenError - can't modify frozen String #982

Closed
wjordan opened this issue Feb 28, 2018 · 0 comments
Closed

FrozenError - can't modify frozen String #982

wjordan opened this issue Feb 28, 2018 · 0 comments

Comments

@wjordan
Copy link
Contributor

wjordan commented Feb 28, 2018

Version: haml master branch (no release version yet), tested on commit e4a8be9.

I produce the following stacktrace when precompiling haml template with tilt via a Sinatra application:

FrozenError - can't modify frozen String:
	[ruby]/gems/tilt-2.0.8/lib/tilt/template.rb:299:in `force_encoding'
	[ruby]/gems/tilt-2.0.8/lib/tilt/template.rb:299:in `ensure in binary'
	[ruby]/gems/tilt-2.0.8/lib/tilt/template.rb:299:in `binary'
	[ruby]/gems/tilt-2.0.8/lib/tilt/template.rb:289:in `extract_magic_comment'
	[ruby]/gems/tilt-2.0.8/lib/tilt/template.rb:285:in `extract_encoding'
	[ruby]/gems/tilt-2.0.8/lib/tilt/template.rb:191:in `precompiled'
	[ruby]/gems/tilt-2.0.8/lib/tilt/template.rb:251:in `compile_template_method'
	[ruby]/gems/tilt-2.0.8/lib/tilt/template.rb:236:in `block in compiled_method'
	[ruby]/gems/tilt-2.0.8/lib/tilt/template.rb:235:in `synchronize'
	[ruby]/gems/tilt-2.0.8/lib/tilt/template.rb:235:in `compiled_method'
	[ruby]/gems/tilt-2.0.8/lib/tilt/template.rb:169:in `evaluate'
	[ruby]/gems/tilt-2.0.8/lib/tilt/haml.rb:24:in `evaluate'
	[ruby]/gems/tilt-2.0.8/lib/tilt/template.rb:109:in `render'
	[ruby]/gems/sinatra-2.0.1.rc1/lib/sinatra/base.rb:839:in `render'
	[ruby]/gems/sinatra-2.0.1.rc1/lib/sinatra/base.rb:692:in `haml'

This issue seems to be caused by setting frozen_string_literal: true on lib/haml/temple_engine.rb (#967), which breaks an implicit contract in the interface between these two gems.

Whether this is a bug best fixed in tilt or haml (or both, for best backwards-forwards compatibility) I don't know, but in any case, tilt's Tilt::HamlTemplate#precompiled_template expects strings returned from calls to Haml::TempleEngine to be not-frozen, because it calls #force_encoding on the returned string.

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

No branches or pull requests

1 participant