Olaf Chitil <[EMAIL PROTECTED]> wrote:
> Runtime errors could be more informative than just stating 
>   "Program error: <erroneous term>" 
> e.g. 
>   No matching pattern
>   in definition of function: f
>   for argument: <arg>
> 
> [Two other requests deleted]

I haven't fixed this problem (yet) - but I've solved a related problem
which might be useful.  The problem is that it's hard to make sense of
an error message like this:

  Program error: {v869 {dict} [v67 1]}

because you don't know what v869 and v67 are.  My patch is to exploit the
parent field of Names and Instances to print more meaningful names:

  Program error: {foo_v869 {dict} [Num_Int_fromInt 1]}

That is, implementations of member functions are disambiguated using the
Class, Instance and member names.  Anonymous functions and explicit case
expressions are disambiguated using the name of the top-level function in
which they are defined.

I don't pretend that this is the best we can do - but it's certainly better
than what we had before.


Enjoy

Alastair


Index: printer.c
diff -r1.16 -r1.18
15,16c15,18
< static Void   local outVar            Args((Text));
< static Void   local outOp             Args((Text));
---
> static Void   local outType                   Args((Type));
> static Void   local outName                   Args((Name));
> static Void   local outVar            Args((Name));
> static Void   local outOp             Args((Name));
183c185
<                               outOp(name(whnfHead).text);
---
>                               outOp(whnfHead);
194c196
<                               outOp(name(whnfHead).text);
---
>                               outOp(whnfHead);
201c203
<                               outVar(name(whnfHead).text);
---
>                               outVar(whnfHead);
434,436c436,470
< static Void local outVar(t)           /* output t as function symbol     */
< Text t; {
<     String s = textToStr(t);
---
> static Void local outType(ty) {            /* output Tycon at head of type */
>     ty = getHead(ty);
>     if (isTycon(ty)) {
>         outStr(textToStr(tycon(ty).text));
>     } else {
>         outCh('?');
>     }
> }
> 
> static Void local outName(nm)  /* output nm using parent field if possible */
> Name nm; {
>     if (isPair(name(nm).parent)) {
>       Pair p = name(nm).parent;
>       Cell f = fst(p);
>       if (isClass(f))
>           outStr(textToStr(cclass(f).text));
>       else {
>           outStr(textToStr(cclass(inst(f).c).text));
>           outCh('_');
>           outType(inst(f).t);
>       }
>       outCh('_');
>       outStr(textToStr(name(snd(p)).text));
>     } else if (isName(name(nm).parent)) {
>       outName(name(nm).parent);
>       outCh('_');
>       outStr(textToStr(name(nm).text));
>     } else {
>       outStr(textToStr(name(nm).text));
>     }
> }
> 
> static Void local outVar(nm)          /* output nm as function symbol    */
> Name nm; {
>     String s = textToStr(name(nm).text);
438c472
<       outStr(s);
---
>       outName(nm);
441c475
<       outStr(s);
---
>       outName(nm);
446,448c480,482
< static Void local outOp(t)            /* output t as operator symbol     */
< Text t; {
<     String s = textToStr(t);
---
> static Void local outOp(nm)           /* output nm as operator symbol    */
> Name nm; {
>     String s = textToStr(name(nm).text);
451c485
<       outStr(s);
---
>       outName(nm);
455c489
<       outStr(s);
---
>       outName(nm);




Reply via email to