Hello, When I try code like the following in (ruby 1.8.4 (2005-12-24) [i386-mswin32]): puts (Class.new do def to_s; 'no bug'; end end.new) I get: -e:1: parse error, unexpected kDO_BLOCK, expecting ')' puts (Class.new do def to_s; 'no bug'; end end.new) ------------------^ -e:1: parse error, unexpected kEND, expecting $ puts (Class.new do def to_s; 'no bug'; end end.new) ----------------------------------------------^ Where am I suppose to put the parenthesis to mimic your work-around. Good day. Yemi Bedu P&R Fasteners 325 Pierce St Somerset, NJ 08873 732-302-3600 -----Original Message----- From: news [mailto:news / sea.gmane.org] On Behalf Of David Smiley Sent: Monday, February 27, 2006 12:05 PM To: ruby-core / ruby-lang.org Subject: parser bug, function call without parens across multiple lines I have encountered a counter-intuitive bug in Ruby's parser. The following sample shows the problem: puts Class.new do def to_s 'no bug' end end.new What do you think the output should be? I think it should clearly be 'no bug' but instead it is '#<Class:0x73be8>' and then an error complaining that there is no method 'new' on 'NilClass'. See, Ruby invokes the call to 'new' AFTER the call to puts. To work around this problem, use of parenthesis are necessary. This problem is NOT there if the code is on one line: puts Class.new {def to_s ; 'no bug'; end }.new The fact that this shows up for the multiple line but not the single line sample should be a sign that there is indeed a problem. And it doesn't matter whether the brackets or do-end notation is used; the results are the same. I encountered this problem when I was using Rails to set the around_filter of a controller by using an anonymous class. I tested this against Ruby 1.8.4. ~ David Smiley MITRE