summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorkrc <unknown>2003-08-19 21:59:40 +0000
committerkrc <unknown>2003-08-19 21:59:40 +0000
commit0f9750be555082f42ac65a5e8029947bf23fc9e2 (patch)
treef8438a60c2ee4565be0b8fd92d1a584b80773d8a /ghc
parentf3c159a95b436082c12b20063c13ab8ffe3da20a (diff)
downloadhaskell-0f9750be555082f42ac65a5e8029947bf23fc9e2.tar.gz
[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.
Diffstat (limited to 'ghc')
-rw-r--r--ghc/compiler/coreSyn/MkExternalCore.lhs3
1 files changed, 2 insertions, 1 deletions
diff --git a/ghc/compiler/coreSyn/MkExternalCore.lhs b/ghc/compiler/coreSyn/MkExternalCore.lhs
index 77c2299d1d..86c77da144 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)