From 5aeafc40cf1dd067fc2627b9c6bfe8d9e074d079 Mon Sep 17 00:00:00 2001 From: sof Date: Fri, 15 Jan 1999 18:32:23 +0000 Subject: [PATCH] [project @ 1999-01-15 18:32:22 by sof] 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 | 22 +++++++++++++++++----- ghc/compiler/parser/utils.h | 1 - 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ghc/compiler/parser/hsparser.y b/ghc/compiler/parser/hsparser.y index 0b5208a..4bd6d8b 100644 --- a/ghc/compiler/parser/hsparser.y +++ b/ghc/compiler/parser/hsparser.y @@ -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". diff --git a/ghc/compiler/parser/utils.h b/ghc/compiler/parser/utils.h index fe8bd73..7b419d4 100644 --- a/ghc/compiler/parser/utils.h +++ b/ghc/compiler/parser/utils.h @@ -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: */ -- 1.7.10.4