Hi all,
I’m experiencing very strange behavior with 1.4.0RC1. The problem is, I
can’t seem to isolate a simple test case, when I extract the offending
code
from my app, everything works fine. The code works fine under builds of
1.4.0dev prior to commit 3f8ac10821a43dd63c1af40b801ba3e7e77f52d4 (found
using git bisect).
The error arises in this code fragment (again, if you try and run this
it
will run correctly, it is just within my app that it doesn’t work)
module Core
Thrown if an illegal element is used to create a Path or if the
syntax
for
creating a Path is not correct
class PathSyntaxError < RuntimeError
end
class Path
extend Forwardable
def_delegators :@path, :<=>, :hash, :each, :each_with_index, :map,
:inject,
:size, :length, :empty?
# Create a new Path
# Parameters:
# - contents: a Path, Symbol, String, Symbol[], String[] or nil.
Strings
and
# Symbols will be parsed, Arrays will be decomposed into Path
elements,
# Paths will be copied and nil will return an empty Path
# Exceptions:
# PathSyntaxError: If contents is of an illegal type
def initialize(contents=nil)
@path = case contents
when NilClass
[]
when String, Symbol
parse(StringScanner.new(contents.to_s))
when Array
contents.map do |e|
case e
when String
e.to_sym
when Array, Path
Path.new(e)
else
e
end
end
when Path
contents.map do |e|
case e
when Path
Path.new(e)
else
e
end
end
else
raise PathSyntaxError, “Un Path puede formarse a partir de otro
Path, un String, un Symbol, un Array de Symbol o String, o nil. Un
#{contents.class} es inaceptable” #<===== This is line 716
end
end
end
end
The error I’m getting is:
/Users/mario/Desktop/abstra.cc/projects/BMClient/src/main/ruby/conf/…/app/core/model.rb:716:in
`raise’: exception object expected (TypeError)
Which, of course, makes absolutely no sense. Now, I added a ‘p contents’
and
‘p contents.class’ at the beginning of the initialize method. It turns
out
contents is nil (and its class IS NilClass).
Which makes even less sense, since it should be caught by the “when
NilClass” at the top of the case. If I change the “when NilClass” to
“when
nil” then the case works fine (but then crashes somewhere else).
So it seems there’s some corruption of SOMEthing happening which is
messing
up the class structure.
Now, looking at the commit where the error first pops up
(3f8ac10821a43dd63c1af40b801ba3e7e77f52d4) things are even
weirder…it’s
just a one-line patch to securerandom.rb.
I’m completely out of options, aside from freezing our environment at
the
previous commit. I don’t think it’s productive to file a bug at this
point
since I really can’t reproduce it. Anybody have any ideas as to what I
can
do, or at least how I can go about isolating the bug?
Thanks,
-Mario.