diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-01-28 23:29:27 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-01-28 23:32:17 +0100 |
commit | 8ed3b8933aa41626664d8577d598526cf1b7b66b (patch) | |
tree | f0c530ee9362e5c7206f78005d9bbe5774a87567 | |
parent | 80b7f9f01f76eb1d068ea9d024e10f00cb3ed231 (diff) |
Fix recursive typedef replacement
-rw-r--r-- | check.hs | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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 |