From 9acc6fbecd5b8c65c1efa6ac4971adbafada05cd Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 16 Jun 2010 12:47:44 +0200 Subject: [PATCH] Don't treat datacon id's as local variables. This ensures that datacon id's get simplified like they should. Previously, this wasn't really needed, since a datacon id would become a constant that could be used in conditional assignments directly. Now, however, there might be more complex ADT's (like the Maybe type), where one of the constructors is without arguments (e.g., Nothing), but assigning the enumeration value directly won't work (it should go into the constructor field). --- clash/CLasH/Normalize/NormalizeTools.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clash/CLasH/Normalize/NormalizeTools.hs b/clash/CLasH/Normalize/NormalizeTools.hs index cdb7ee0..eff8b67 100644 --- a/clash/CLasH/Normalize/NormalizeTools.hs +++ b/clash/CLasH/Normalize/NormalizeTools.hs @@ -216,7 +216,10 @@ isRepr' tything = case CoreTools.getType tything of is_local_var :: CoreSyn.CoreExpr -> TranslatorSession Bool is_local_var (CoreSyn.Var v) = do bndrs <- getGlobalBinders - return $ v `notElem` bndrs + -- A datacon id is not a global binder, but not a local variable + -- either. + let is_dc = Id.isDataConWorkId v + return $ not is_dc && v `notElem` bndrs is_local_var _ = return False -- Is the given binder defined by the user? -- 2.30.2