From: sof Date: Thu, 21 Jan 1999 20:02:45 +0000 (+0000) Subject: [project @ 1999-01-21 20:02:43 by sof] X-Git-Tag: Approx_2487_patches~26 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=718754ae4f9230b9ecb2e0e47e25e1e101bfe41b;p=ghc-hetmet.git [project @ 1999-01-21 20:02:43 by sof] Robustified derived toEnum methods; gives better error message when passed enum tags < 0. --- diff --git a/ghc/compiler/prelude/PrelInfo.lhs b/ghc/compiler/prelude/PrelInfo.lhs index 6c4049e..830247a 100644 --- a/ghc/compiler/prelude/PrelInfo.lhs +++ b/ghc/compiler/prelude/PrelInfo.lhs @@ -606,7 +606,7 @@ deriving_occ_info , (ordClassKey, [intTyCon_RDR, compose_RDR, eqTag_RDR]) -- EQ (from Ordering) is needed to force in the constructors -- as well as the type constructor. - , (enumClassKey, [intTyCon_RDR, map_RDR, plus_RDR, showsPrec_RDR, append_RDR]) + , (enumClassKey, [intTyCon_RDR, and_RDR, map_RDR, plus_RDR, showsPrec_RDR, append_RDR]) -- The last two Enum deps are only used to produce better -- error msgs for derived toEnum methods. , (boundedClassKey, [intTyCon_RDR]) diff --git a/ghc/compiler/typecheck/TcGenDeriv.lhs b/ghc/compiler/typecheck/TcGenDeriv.lhs index cab4e7c..09e4992 100644 --- a/ghc/compiler/typecheck/TcGenDeriv.lhs +++ b/ghc/compiler/typecheck/TcGenDeriv.lhs @@ -483,11 +483,16 @@ gen_Enum_binds tycon to_enum = mk_easy_FunMonoBind tycon_loc toEnum_RDR [a_Pat] [] $ - HsIf (HsApp (HsApp (HsVar gt_RDR) - (HsVar a_RDR)) - (HsVar (maxtag_RDR tycon))) - (illegal_toEnum_tag occ_nm (maxtag_RDR tycon)) + HsIf (HsApp (HsApp + (HsVar and_RDR) + (HsApp (HsApp (HsVar ge_RDR) + (HsVar a_RDR)) + (HsLit (HsInt 0)))) + (HsApp (HsApp (HsVar le_RDR) + (HsVar a_RDR)) + (HsVar (maxtag_RDR tycon)))) (mk_easy_App (tag2con_RDR tycon) [a_RDR]) + (illegal_toEnum_tag occ_nm (maxtag_RDR tycon)) tycon_loc enum_from