Quality of error messages

Sent: Friday, October 08, 2004 1:39 PM
To: ruby-talk@ruby-lang.org
Subject: Re: quality of error messages

>
> > > Hi,
> > >
> > >
> > > >> 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.
> > >
> >
> >
> > ((1+2)+3+4/5
> >
> > 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..
>
> A "missing partner foo-end on possible foo-begin in line#"
message is
> a lot better than just plain "syntax error".
>
> Is that fine enough?

     Sorry, my example over simplified a little. To save
space, I was using an analogy between class/end and '('/')';
and I chose a example that was too simple to really make the point.

     Consider that each token is on its own line (i.e., that
we really are wanting to identify which '(' is missing its
')', not even worrying about where it goes). Also keep in
mind that nested things like '((3))' are valid (and meaningful)*:

   (((1/2)/((3/4)/5)

(
(
  (1/2)
   /
  (
   (3/4)
    /
    5
  )

we catch only one (though there are two). And to simplify further, we point
second "(" since it is _inner... But I do not know internal parser. if
parser catches first "(", then it reports first "(". Does not matter w me.

So, which '(' is missing its ')'?

again, we do _not choose or point where _exactly.

we only say "missing foo-end on possible foo-begin at line#". Compiler
suggest. The programmer will decide.

-- Markus

kind regards -botp

···

Markus [mailto:markus@reality.com] wrote:

On Thu, 2004-10-07 at 22:26, "Peña, Botp" wrote:
> Markus [mailto:markus@reality.com] wrote:
> > On Thu, 2004-10-07 at 21:19, Yukihiro Matsumoto wrote:
> > > In message "Re: quality of error messages" > > > > on Fri, 8 Oct 2004 12:58:26 +0900, Jamis Buck > > > <jgb3@email.byu.edu> > > > > writes:

>
> Sorry, my example over simplified a little. To save
> space, I was using an analogy between class/end and '('/')';
> and I chose a example that was too simple to really make the point.
>
> Consider that each token is on its own line (i.e., that
> we really are wanting to identify which '(' is missing its
> ')', not even worrying about where it goes). Also keep in
> mind that nested things like '((3))' are valid (and meaningful)*:
>
> (((1/2)/((3/4)/5)

we catch only one (though there are two). And to simplify further, we point
second "(" since it is _inner... But I do not know internal parser. if
parser catches first "(", then it reports first "(". Does not matter w me.

     But why the second "("? It could be any of them, with equal
likelihood (indicating added ")" as "]" and its partner as "]", and
looking, as you did, for only one of the two that are missing):

    ([(1/2)]/((3/4)/5)
    (([1]/2)/((3/4)/5)
    (((1/2)/[(3/4)]/5)
    (((1/2)/([3]/4)/5)

...and the first "(" might well be one of the ones missing a ")" if we
account for the fact that there are two missing:

    [[(1/2)]/((3/4)/5)]
    [([1]/2)/((3/4)/5)]
    [((1/2)/[(3/4)]/5)]
    [((1/2)/([3]/4)/5)]
    ([[1/2])]/((3/4)/5)
    ([[1]/2)]/((3/4)/5)
    ([(1/2)]/[(3/4)]/5)
    ([(1/2)]/([3]/4)/5)
    ([[1]/2)]/((3/4)/5)
    (([1]/2)/[(3/4)]/5)
    (([1]/2)/([3]/4)/5)
       :
       :

For a reasonable sized program, the possibilities are enormous. If all
the hinter is going to do is point out some construct that takes an
'end' at random, how does that help you?

>
> So, which '(' is missing its ')'?
>

again, we do _not choose or point where _exactly.

we only say "missing foo-end on possible foo-begin at line#". Compiler
suggest. The programmer will decide.

     But if the compiler doesn't have some system (and this is exactly
the point I believe matz was asking about) to narrow down the
possibilities somewhat, it isn't helping the programmer--and may be
doing harm, through misdirection.

    -- Markus

···

On Thu, 2004-10-07 at 22:57, "Peña, Botp" wrote:

Markus [mailto:markus@reality.com] wrote: