From: krc Date: Tue, 19 Aug 2003 21:59:40 +0000 (+0000) Subject: [project @ 2003-08-19 21:59:40 by krc] X-Git-Tag: Approx_11550_changesets_converted~545 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=0f9750be555082f42ac65a5e8029947bf23fc9e2 [project @ 2003-08-19 21:59:40 by krc] Two issues: 1. According to the spec for External Core, datatype declarations are required to have at least one data constructor. Previously, if you tried to generate External Core for a program containing a datatype declaration with no constructors, generating the Core file would succeed, but compiling it would result in a parse error. Changed MkExternalCore to signal an error if such a declaration is encountered while compiling to External Core. 2. Previously, MachLabel literals were translated into Externals when compiling to External Core. This is wrong -- such literals are not foreign calls and can't be handled in the same way (compiling any External Core code generated from code containing literals resulting from "foreign label" declarations would result in a strange error message). There doesn't seem to be any way to correctly represent these labels in External Core, so MkExternalCore now signals an error if one of these is encountered as well. --- diff --git a/ghc/compiler/coreSyn/MkExternalCore.lhs b/ghc/compiler/coreSyn/MkExternalCore.lhs index 77c2299..86c77da 100644 --- a/ghc/compiler/coreSyn/MkExternalCore.lhs +++ b/ghc/compiler/coreSyn/MkExternalCore.lhs @@ -96,6 +96,7 @@ collect_tdefs tcon tdefs where tdef | isNewTyCon tcon = C.Newtype (make_con_qid (tyConName tcon)) (map make_tbind tyvars) repclause + | null (tyConDataCons tcon) = error "MkExternalCore died: can't handle datatype declarations with no data constructors" | otherwise = C.Data (make_con_qid (tyConName tcon)) (map make_tbind tyvars) (map make_cdef (tyConDataCons tcon)) where repclause | isRecursiveTyCon tcon = Nothing @@ -135,7 +136,7 @@ make_exp (Var v) = FCallId (CCall (CCallSpec (StaticTarget nm) _ _)) -> C.External (unpackFS nm) (make_ty (varType v)) FCallId _ -> error "MkExternalCore died: can't handle non-static-C foreign call" _ -> C.Var (make_var_qid (Var.varName v)) -make_exp (Lit (l@(MachLabel s _))) = C.External (unpackFS s) (make_ty (literalType l)) +make_exp (Lit (l@(MachLabel s _))) = error "MkExternalCore died: can't handle \"foreign label\" declarations" make_exp (Lit l) = C.Lit (make_lit l) make_exp (App e (Type t)) = C.Appt (make_exp e) (make_ty t) make_exp (App e1 e2) = C.App (make_exp e1) (make_exp e2)