[project @ 1999-01-15 18:32:22 by sof]
authorsof <unknown>
Fri, 15 Jan 1999 18:32:23 +0000 (18:32 +0000)
committersof <unknown>
Fri, 15 Jan 1999 18:32:23 +0000 (18:32 +0000)
Be a little bit more user-friendly when encountering record puns,
which is no longer supported by Haskell. Instead of a Plain Old Parse
Error, print out

  foo.hs:11:11: Haskell 98 does not support 'punning' on records ....

Hopefully that should give the user a big enough hint at what's
going wrong..

ghc/compiler/parser/hsparser.y
ghc/compiler/parser/utils.h

index 0b5208a..4bd6d8b 100644 (file)
@@ -61,6 +61,11 @@ extern int modulelineno;
 extern int startlineno;
 extern int endlineno;
 
+/* Local helper functions */
+static void checkinpat        PROTO((void));
+static void punningNowIllegal PROTO((void));
+
+
 /**********************************************************************
 *                                                                     *
 *                                                                     *
@@ -1090,8 +1095,9 @@ rbinds1   :  rbind                                { $$ = lsing($1); }
        |  rbinds1 COMMA rbind                  { $$ = lapp($1,$3); }
        ;
 
-rbind          :  qvar EQUAL exp                       { $$ = mkrbind($1,mkjust($3)); }
-;      
+rbind          : qvar                                  { punningNowIllegal();         }
+       | qvar EQUAL exp                        { $$ = mkrbind($1,mkjust($3)); }
+       ;       
 
 texps  :  exp                                  { $$ = lsing($1); }
        |  exp COMMA texps                      { $$ = mklcons($1, $3) }
@@ -1298,7 +1304,8 @@ rpats1    : rpat                                  { $$ = lsing($1); }
        | rpats1 COMMA rpat                     { $$ = lapp($1,$3); }
        ;
 
-rpat   :  qvar EQUAL pat                       { $$ = mkrbind($1,mkjust($3)); }
+rpat   : qvar                                  { punningNowIllegal();         } 
+       | qvar EQUAL pat                        { $$ = mkrbind($1,mkjust($3)); }
        ;
 
 
@@ -1622,13 +1629,18 @@ vccurly1:
 **********************************************************************/
 
 
-void
-checkinpat()
+static void checkinpat()
 {
   if(pat_check)
     hsperror("pattern syntax used in expression");
 }
 
+static void punningNowIllegal()
+{
+  hsperror("Haskell 98 does not support 'punning' on records");
+}
+
+
 /* The parser calls "hsperror" when it sees a
    `report this and die' error.  It sets the stage
    and calls "yyerror".
index fe8bd73..7b419d4 100644 (file)
@@ -92,7 +92,6 @@ void   hsindentoff PROTO((void));
 
 int     checkfixity PROTO((char *));
 void    checksamefn PROTO((tree));
-void    checkinpat PROTO((void));
 
 void    expORpat PROTO((int,tree));
 /* the "int" arg says what we want; it is one of: */