Don't treat datacon id's as local variables.
[matthijs/master-project/cλash.git] / clash / CLasH / Normalize / NormalizeTools.hs
index cdb7ee01352a85fca6cf080de9019259c359d632..eff8b67db39798b020e8523d8f28524cc8efaa4f 100644 (file)
@@ -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?