Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Incorrect use of || breaks helpers in Ruby 1.9

#10

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.

Reported by Benedict Eastaugh · January 18th, 2010 @ 01:36 PM

State: resolved
Milestone: none
Assigned to: Stephen Bartholomew Stephen Bartholomew

Activity

  1. Benedict Eastaugh
    Benedict Eastaugh

    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.

    January 18th, 2010 @ 01:38 PM

  2. Stephen Bartholomew
    Stephen Bartholomew
    • 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

    January 25th, 2010 @ 11:48 AM

  3. Stephen Bartholomew
    Stephen Bartholomew
    • State changed from open to resolved

    April 19th, 2010 @ 08:38 PM

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.