[EMAIL PROTECTED] writes:
> A typo which should cause a type error produces instead
> an Hugs 1.4 internal error:
>
> data C = C { p :: Int}
> a c = C (p = p c)     -- typo: () instead of {}
>
> --------------------------------------
> Dependency analysis
> INTERNAL ERROR: in depExpr
> --------------------------------------

Actually, it should cause a parse error since this isn't legal Haskell
syntax - but it is legal TREX syntax.  (TREX - Typed Records with
EXtensions - are pretty cool but they're off by default.)

Here's a patch which catches every use of TREX-specific syntax and 
prints a mildly useful error message instead.

diff -r1.16 parser.y
45a46,48
> #if !TREX
> static Void   local noTREX       Args((String));
> #endif
385c388,394
< lacks     : varid1 '\\' varid1                {$$ = gc3(ap(mkExt(textOf($3)),$
1));}
---
> lacks     : varid1 '\\' varid1                {
> #if TREX
>                                          $$ = gc3(ap(mkExt(textOf($3)),$1));
> #else
>                                          noTREX("a type context");
> #endif
>                                         }
428c437
<                                          $$ = gc3(NIL);
---
>                                          noTREX("a type");
630c639,645
< vfield          : qvarid '=' exp              {$$ = gc3(ap(mkExt(textOf($1)),$
3));}
---
> vfield          : qvarid '=' exp              {
> #if TREX
>                                          $$ = gc3(ap(mkExt(textOf($1)),$3));
> #else
>                                          noTREX("an expression");
> #endif
>                                         }
958a974,982
>
> #if !TREX
> static Void local noTREX(where)
> String where; {
>     ERRMSG(row) "Attempt to use Typed Records with Extensions\nwhile parsing %
s. This feature is disabled in this build of Hugs.",
>                  where
>     EEND;
> }
> #endif

[The rule for making parser.c from parser.y is commented out in the
Makefile since we assume that you don't have a working yacc on your
system.  On PCs, this is a fairly safe assumption since neither byacc
nor bison produce working parser.c's.]

It'd be nicer to just disable the syntax rules altogether - but then you
have to preprocess the grammar which doesn't work.

> This happens on a PC and on a Sun4 running SunOS 4.1.3,
> but not on a Sun running 5.5.1.

Yoiks.  I can't imagine why it wouldn't show up on Solaris.  Can you
check again?


Alastair

Reply via email to