From 6953939e4af88c0d3219ca5e3f1d661bef115d37 Mon Sep 17 00:00:00 2001 From: Fedor Isakov Date: Fri, 28 Dec 2018 11:47:46 +0100 Subject: [PATCH] Report unification of a logical with itself as a failure. --- reactor/Core/src/jetbrains/mps/logic/reactor/core/Logical.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/Logical.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/Logical.kt index 72bc56d7..adaadbc1 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/Logical.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/Logical.kt @@ -118,6 +118,10 @@ class LogicalImpl : JoinableLogical { val thisRepr = this.find() val otherRepr = (other as LogicalImpl).find() + if (thisRepr === otherRepr) { + throw IllegalStateException("cannnot unite logical with itself") + } + // invariant: thisRepr.rank > otherRepr.rank if (thisRepr.rank() < otherRepr.rank()) { otherRepr.union(thisRepr, reconciler);