From ba636e1da048444c34e1870bf51b995337842de5 Mon Sep 17 00:00:00 2001 From: Florian Steurer Date: Tue, 12 Apr 2016 15:17:12 +0200 Subject: [PATCH] fixed bug in standard unify --- .../unify/MartelliMontanariUnify.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/de/dhbwstuttgart/typeinference/unify/MartelliMontanariUnify.java b/src/de/dhbwstuttgart/typeinference/unify/MartelliMontanariUnify.java index 45e52133..40da3cf9 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/MartelliMontanariUnify.java +++ b/src/de/dhbwstuttgart/typeinference/unify/MartelliMontanariUnify.java @@ -57,8 +57,7 @@ public class MartelliMontanariUnify implements IUnify { } // REDUCE - Rule - if(!(rhsType instanceof PlaceholderType) && !(lhsType instanceof PlaceholderType) - && (rhsTypeParams.size() != 0 || lhsTypeParams.size() != 0)) { + if(!(rhsType instanceof PlaceholderType) && !(lhsType instanceof PlaceholderType)) { Set result = new HashSet<>(); // f<...> = g<...> with f != g are not unifiable @@ -68,13 +67,15 @@ public class MartelliMontanariUnify implements IUnify { if(rhsTypeParams.size() != lhsTypeParams.size()) return Optional.empty(); // conflict - // Unpack the arguments - for(int i = 0; i < rhsTypeParams.size(); i++) - result.add(new UnifyPair(rhsTypeParams.get(i), lhsTypeParams.get(i), PairOperator.EQUALSDOT)); - - termsList.remove(idx); - termsList.addAll(result); - continue; + if(rhsTypeParams.size() != 0) { + // Unpack the arguments + for(int i = 0; i < rhsTypeParams.size(); i++) + result.add(new UnifyPair(rhsTypeParams.get(i), lhsTypeParams.get(i), PairOperator.EQUALSDOT)); + + termsList.remove(idx); + termsList.addAll(result); + continue; + } } // SWAP - Rule