summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-01-28 23:29:27 +0100
committertomsmeding <tom.smeding@gmail.com>2017-01-28 23:32:17 +0100
commit8ed3b8933aa41626664d8577d598526cf1b7b66b (patch)
treef0c530ee9362e5c7206f78005d9bbe5774a87567
parent80b7f9f01f76eb1d068ea9d024e10f00cb3ed231 (diff)
Fix recursive typedef replacement
-rw-r--r--check.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/check.hs b/check.hs
index fd94f0d..d2a7c92 100644
--- a/check.hs
+++ b/check.hs
@@ -30,9 +30,14 @@ replaceTypes prog@(Program decls) = mapProgram' filtered mapper
notTypedef _ = True
typeReplacer :: Map.Map Name Type -> Type -> Type
- typeReplacer m t@(TypeName n) = maybe t id $ Map.lookup n m
+ typeReplacer m t@(TypeName n) = maybe t (recurseAfter m) $ Map.lookup n m
typeReplacer _ t = t
+ recurseAfter :: Map.Map Name Type -> Type -> Type
+ recurseAfter m t@(TypeName _) = typeReplacer m t
+ recurseAfter m (TypePtr t) = TypePtr $ recurseAfter m t
+ recurseAfter _ t = t
+
findTypeRenames :: Program -> Map.Map Name Type
findTypeRenames (Program d) = foldl go Map.empty d
where