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);