diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Signature.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Signature.kt index 02c60ff46..ac068df91 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Signature.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Signature.kt @@ -93,9 +93,9 @@ data class Signature( ) } args.last().let { - it is Struct && functor == varargStructFunctor && arity == 2 && - args.first().isInt && - args.last() == varargAtom + it is Struct && it.functor == varargStructFunctor && it.arity == 2 && + it.args.first().isInt && + it.args.last() == varargAtom } -> { Signature( args.first().`as`().value, diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/SignatureTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/SignatureTest.kt index fe86b4856..1a180923a 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/SignatureTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/SignatureTest.kt @@ -100,7 +100,11 @@ internal class SignatureTest { @Test fun fromTermWithStructCreatesCorrectInstance() { - signatures.forEach { assertEquals(it, Signature.fromSignatureTerm(it.toTerm()) ?: fail()) } + signatures.forEach { + val reconstructed = Signature.fromSignatureTerm(it.toTerm()) + ?: fail("Cannot reconstruct signature $it from it.toTerm(): ${it.toTerm()}") + assertEquals(it, reconstructed) + } signatureTerms.zip(signatures).forEach { (signatureTerm, signature) -> assertEquals(signature, Signature.fromSignatureTerm(signatureTerm) ?: fail())