Incorrect use of || breaks helpers in Ruby 1.9
Reported by Benedict Eastaugh | January 18th, 2010 @ 01:36 PM
The problem with the following line ought to be obvious:
'@staticmatic'
, being truthy, will always be the
result of the disjunction.
@scope.instance_variable_set(var, nil) unless var == ('@staticmatic' || :@staticmatic)
This is a problem on Ruby 1.9, where instance variables names are always set to symbols, even if strings are used in the setters (as they are in Staticmatic). Consider this example script:
obj = Object.new
obj.instance_variable_set("@myvar", "Test.")
obj.instance_variables.each do |var|
puts var.class
end
Ruby 1.8.x will print String
; Ruby 1.9.x will print
Symbol
.
Patch is attached.
Comments and changes to this ticket
-
Benedict Eastaugh January 18th, 2010 @ 01:38 PM
It might, of course, be preferable to stop setting the names of instance variables to strings altogether, but I don't know whether there's some underlying reason it's done like this.
-
Stephen Bartholomew January 25th, 2010 @ 11:48 AM
- State changed from new to open
Wow - that's a pretty dumb bug - I'll get that sorted for the next release.
Thanks for the patch.
Steve
-
Stephen Bartholomew April 19th, 2010 @ 08:38 PM
- State changed from open to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Light-weight static site framework