From 8ed3b8933aa41626664d8577d598526cf1b7b66b Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 28 Jan 2017 23:29:27 +0100 Subject: Fix recursive typedef replacement --- check.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3-70-g09d2