diff --git a/ghc/compiler/parser/hsparser.y b/ghc/compiler/parser/hsparser.y index 0b5208a8c106b832b4d20ee5c62721705dfd5837..4bd6d8b5211b9a9c896d6b86e9508129de60e076 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 fe8bd7304a4eef77a25662725450a2f662022b1d..7b419d4ce29f2cf7da9983a63feeec10b97a98c1 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: */