From: Brian Candler Date: 2004-10-08T18:19:50+09:00 Subject: Re: quality of error messages On Fri, Oct 08, 2004 at 02:26:26PM +0900, "Pe?a, Botp" wrote: > > There is clearly a ')' missing, but should it be: > > > > > > ((1)+2)+3+4/5 which equals 6.8 > > > [snip informative text] > > > no, we do not have to determine where_ to put the missing ")". We can be > close to the target, but not closer, pls. > > as for ((1+2)+3+4/5 > > the compiler just say that the first "(" has missing ")". That is all. (1+2) > pair is already valid, and therefore consumes the last ")" which leaves the > first "(" missing a partner. Of course, this may not be what the programmer > wants, but hey, the compiler was just helping. Was it helpful? Many a times, > yes.. I think in most cases not. For the most common missing 'end' error, the compiler detects it at the end of the file, and the line it thinks it pairs with is the first line of the file. Hence it localises the error to somewhere between the first line and last line of the file, which is not very helpful :-) Concrete example: class A def m1 end def m2 if true puts "hello" end def m3 end end class B def m1 end def m2 end def m3 end end class C end is parsed as: class A def m1 end def m2 if true puts "hello" end def m3 end end class B def m1 end def m2 end def m3 end end class C end Since class definitions can occur within other classes (very useful), and 'def' can occur within another 'def' (not so useful for me), that's how it gets parsed. Regards, Brian.