Commit 718754ae authored by sof's avatar sof
Browse files

[project @ 1999-01-21 20:02:43 by sof]

Robustified derived toEnum methods; gives better error message when
passed enum tags < 0.
parent 0a8369c6
......@@ -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])
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment