the blog
Back to -Blog

Ruby’s Strange Warning

Problems Caused By A Single Space...
by Dermot Hogan
Wednesday 14 June 2006.

I came across a debugger peculiarity reported by a user of Steel 0.6 recently. The symptom was a rather strange error message appended to the result of querying a database using DBI.

At the end of the dataset, the text “C:\Program Files\SapphireSteel\Steel\v1.0\Ruby\xdebug.rb:141: warning: (...) interpreted as grouped expression” popped up. The Ruby expression in question was the line:

catch (:error) do

Strangely, the warning went away if I changed the line to

catch :error do

or:

catch(:error) do

Notice that I’ve just deleted the space character between catch and the opening bracket in the last version above.

After a bit of head scratching, I tracked this down to the first line of the script that was being debugged. It was this:

#!/usr/bin/env ruby -w

Removing the –w caused the warning to disappear. So, it seems that Ruby was reading the first line of the text (under Windows don’t forget, not Unix) and turning on warnings. This then triggered the warning on the catch line. I don’t know if Ruby is supposed to look at comment lines like this in Windows, but it certainly looks as if it did.

But (even more weirdly) altering the line to remove the space before the opening bracket caused the warning to go away: why should removing a space do that?

This illustrates one of the problems in trying to work with Ruby from a tools perspective – it just does unpredicatable things. Trying to parse error messages is hit and miss. All I can do is apply some heuristics to try and get sense out of most of the error messages most of the time...

Bookmark and Share   Keywords:  development
  • Ruby’s Strange Warning
    9 October 2008, by coder2000

    the #! has special meaning and it comes from unix. it is called the shebang and tells the console which interpreter to run the script through and what options to use. so yes it is a good thing that ruby in steel is using the options specified in the shebang properly.

© SapphireSteel Software 2014