Bugs: Browse | Submit New | Admin

[#9698] $'.length only appliable to String-Class

Date:
2007-03-30 13:29
Priority:
3
Submitted By:
Nobody
Assigned To:
Nobody (None)
Category:
Core
State:
Open
Summary:
$'.length only appliable to String-Class

Detailed description
C:/jruby/lib/ruby/gems/1.8/gems/needle1.3.0/lib/needle/logger.rb:121:in `method_missing': undefined method `length'
for :NilClass (NoMethodError)

the failing line:

     format_string << $' if $'.length > 0

the error only occurs in jruby, but the bug would propably apply to both worlds:

$ ruby -e "la= \"lulu\"; la =~ /m/; p $'.length() "
-e:1: undefined method `length' for nil:NilClass (NoMethodError)

$ ruby -e "la= \"lulu\"; la =~ /m/; p $'.length "
-e:1: undefined method `length' for nil:NilClass (NoMethodError)

$ ruby -e "la= \"lulu\"; la =~ /lu/; p $'.length "
2

$ ruby -e "la= \"lulu\"; la =~ /m/; p $'.instance_of?(String) "
false

$ ruby -e "la= \"lulu\"; la =~ /lu/; p $'.instance_of?(String) "
true

so we probably have to check first, wheater $' is actually a String. e.g.

     format_string << $' if $'.length > 0 if $'.instance_of?(String)

so long,
                           /fux
PS: the issue with jruby still is:
 ruby output: # Logfile created on Fri Mar 30 15:04:38 +0200 2007 by logger.rb/1.5.2.9
jruby output: # Logfile created on Fri Mar 30 15:15:11 CEST 2007 by /

but at least it's not exiting abnormaly... :)

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item