Skip to content

Commit 84b8360

Browse files
committed
Only expand fully applied macros
1 parent b51dc4f commit 84b8360

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

UDAnnotations.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,13 @@ catsForPOS env = M.fromListWith (++) $
287287
-- CId (AbsType,(([CId],AbsTree),[Label]))
288288
expandMacro :: UDEnv -> AbsTree -> AbsTree
289289
expandMacro env tr@(RTree f ts) = case M.lookup f (macroFunctions (cncLabels env)) of
290-
Just (MacroFunction _ xx df _) -> subst (zip xx (map (expandMacro env) ts)) df
291-
_ -> RTree f (map (expandMacro env) ts)
290+
Just (MacroFunction _ xx df _) | length ts' == length xx ->
291+
subst (zip xx ts') df
292+
_ -> RTree f ts'
292293
where
293-
subst xts t@(RTree h us) = case us of
294+
ts' = map (expandMacro env) ts
295+
subst xts t@(RTree h us) =
296+
case us of
294297
[] -> maybe t id (lookup h xts)
295298
-- Expand head: #auxfun Ex a b : A -> B -> C = a b ; cn head
296299
_ | Just (RTree h' hus) <- lookup h xts -> expandMacro env $ RTree h' (hus ++ map (subst xts) us)

0 commit comments

Comments
 (0)