banister / method_source

return the sourcecode for a method
MIT License
361 stars 43 forks source link

Improve frozen-string-literals compatibility. #47

Closed pat closed 7 months ago

pat commented 7 years ago

A few simple changes to allow this gem to be used when RUBYOPT="--enable-frozen-string-literal" is set in MRI 2.4+.

However, it's worth noting that Bacon isn't frozen-string-literal friendly, so the test suite can't be run with this flag. I've addressed this in a PR, but there hasn't been a gem release of Bacon for quite some time (as noted in #45) - so it's worth considering changing to a git repo reference in the Gemfile? This way, you'll be able to add the RUBYOPT flag for 2.4+ versions of Ruby in your test suite and avoid regression errors :)

jhawthorn commented 8 months ago

It's likely Ruby 3.4 will ship with a warning for libraries incompatible with --enable-frozen-string-literal with the intention to make that a default in a future version.

It would be great to have an updated version of method_source with this fix.

casperisfine commented 8 months ago

Seconding this :)