Project

General

Profile

Actions

Bug #1140

closed

Parsing error gives method_missing a nonexistant method name

Added by simian (Ben Rayfield) over 15 years ago. Updated over 13 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
[ruby-core:21964]

Description

=begin
This does not happen consistently but I have seen it about 5 times.

My operating system is Windows Server 2003 SP2.

my code: def method_missing method_name, *params

method_name.inspect is :backgroundColor=

Maybe I dont understand how method names are represented, but I thought the method name should be "backgroundColor" or "=" but not the concat of both.

Parsing fails in element.rb, which I attached:

def highlight(set_or_clear)
if set_or_clear == :set
begin
@original_color ||= style.backgroundColor
style.backgroundColor = @container.activeObjectHighLightColor
rescue
@original_color = nil
end
else # BUG: assumes is :clear, but could actually be anything
begin
style.backgroundColor = @original_color unless @original_color == nil
rescue
# we could be here for a number of reasons...
# e.g. page may have reloaded and the reference is no longer valid
ensure
@original_color = nil
end
end
end

...my code...:238:in method_missing' c:/ruby/rubyinstalled/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/element.rb:194: in highlight'
c:/ruby/rubyinstalled/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/element.rb:227:
in click!' c:/ruby/rubyinstalled/lib/ruby/gems/1.8/gems/watir-1.5.3/./watir/element.rb:209: in click'
...my code...
=end


Files

element.rb (9.14 KB) element.rb where it parses wrong simian (Ben Rayfield), 02/11/2009 05:00 AM
Actions #1

Updated by pit (Pit Capitain) over 15 years ago

=begin
Ben, if you "don't understand how method names are represented" then why are you entering this as a bug instead of reading one of Ruby's introductory books or asking on the mailing list? Don't you think the maintainers of Ruby should better spend their time improving Ruby instead of answering questions like yours?
=end

Actions #2

Updated by simian (Ben Rayfield) over 15 years ago

=begin
Please close this as Not-A-Bug.

I apologise for not finding this earlier:

"Methods that end with an equals sign (=) are special because Ruby allows them to be invoked using assignment syntax. If an object o has a method named x=, then the following two lines of code do the very same thing:
o.x=(1) # Normal method invocation syntax
o.x = 1 #Method invocation through assignment"

http://books.google.com/books?id=jcUbTcr5XWwC&pg=PA6&lpg=PA6&dq=ruby+method+equals&source=web&ots=fHDkwd7ybC&sig=nI4zpxc836knAK1hIx0rXXiFcOQ&hl=en&ei=MqyVSfPGB4risAPh--W-Bw&sa=X&oi=book_result&resnum=1&ct=result#PPA6,M1

I have fixed my problem by putting the method_missing in a class instead of in global code where it replaced the method_missing in element.rb.
=end

Actions #3

Updated by matz (Yukihiro Matsumoto) over 15 years ago

  • Status changed from Open to Closed

=begin

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0