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

Gem depends on #inspect producing valid Ruby code #972

Closed
ngollan opened this issue Jan 4, 2018 · 4 comments
Closed

Gem depends on #inspect producing valid Ruby code #972

ngollan opened this issue Jan 4, 2018 · 4 comments

Comments

@ngollan
Copy link

ngollan commented Jan 4, 2018

Trying to produce shorter/prettier (no accounting for taste) inspect output and overriding TrueClass/FalseClass#inspect breaks "optimisation" with something like:

undefined local variable or method `⊤' for #<Haml::AttributeCompiler:0x007f1a0304c648>

in Haml::AttributeCompiler#static_build.

I have true/false represented by "⊤" and "⊥" via

TrueClass.class_eval do
  def inspect
    "⊤"
  end
end

FalseClass.class_eval do
  def inspect
    "⊥"
  end
end
@HamptonMakes
Copy link
Member

@ngollan do you have a sample of this override? Or, a gem that does this?

@k0kubun
Copy link
Member

k0kubun commented Feb 19, 2018

do you have a sample of this override? Or, a gem that does this?

Having the attached code somewhere before Haml template compilation would reproduce this. It's my fault on Haml 5.

TrueClass.class_eval do
  def inspect
    "⊤"
  end
end

FalseClass.class_eval do
  def inspect
    "⊥"
  end
end

@ngollan
Copy link
Author

ngollan commented Jun 21, 2020

I had not expected this "issue" to get fixed ;-) Anyway, the test in the referenced commit overrides TrueClass#inspect twice instead of having one override for FalseClass.

@k0kubun
Copy link
Member

k0kubun commented Jun 21, 2020

the test in the referenced commit overrides TrueClass#inspect twice instead of having one override for FalseClass.

Good eye! Fixed it b564537

bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this issue Jan 22, 2021
https://build.opensuse.org/request/show/865194
by user coolo + dimstar_suse
updated to version 5.2.1
 see installed CHANGELOG.md
  ## 5.2.1

  Released on November 30, 2020
  ([diff](haml/haml@v5.2.0...v5.2.1)).

  * Add in improved "multiline" support for attributes [#1043](haml/haml#1043)

  ## 5.2

  Released on September 28, 2020
  ([diff](haml/haml@v5.1.2...v5.2.0)).

  * Fix crash in the attribute optimizer when `#inspect` is overridden in TrueClass / FalseClass [#972](haml/haml#972)
  * Do not HTML-escape templates that are declared to be plaintext [#1014](haml/haml#1014) (Thanks [@cesarizu](https://github.com/cesarizu))
  * Class names are no longer ordered alphabetically, and now follow a new specification as laid ou
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants