From: Hal Fulton Date: 2004-10-08T14:38:38+09:00 Subject: Re: quality of error messages Yukihiro Matsumoto wrote: > Hi, > > In message "Re: quality of error messages" > on Fri, 8 Oct 2004 12:58:26 +0900, Jamis Buck writes: > > |> We can. But how we check for missing/broken def/end pairs, more than > |> just syntax error? > > |I believe what is being asked for is more than just a "syntax error" > |message. If the error could be more specific, like "missing 'end' on > |line x", it would greatly increase the usefulness of the -c option. > > I know what he wants. I am not refusing his idea. The point is I'm > not yet sure how to detect missing pairs. Well, I had an idea once, but I considered it too dumb to share. I am opposed to the use of "significant whitespace" as in Python. But having said that, it is always wise to indent intelligently, most of us do it in one way or another. It would be theoretically possible to match by indentation as well as keyword (solely for these purposes, and only with -c). For example: 1| class Foo 2| class Bar 3| def mymeth(x) 4| if x.nil? 5| puts "x is nil" 6| end 7| end 8| end If we do this kind of guessing, we will guess that there is a missing end after line 5. (Because the end doesn't match the indentation of the 'if' to which it corresponds.) If we don't, we will go past line 8 until we hit something we can't handle. It may be line 10 or line 999. This is a very common error for me, and I have thought of writing a little tool just to find missing ends (since my own indentation is always consistent enough to allow it). Hal