i4niac

Member

Last active 4 years ago

  1. 4 years ago
    Sun 21 Sep 2014 03:15:24 AM CEST

    Did you check with Xcode 6 GM?
    In any case, just break it into a smaller bits, for example

    return a == b && c == d && e == f && g == h


    break it like this

    let condition1 = (a == b && c == d)
    let condition2 = (e == f && g == h)
    return condition1 && condition2

    I didn't check the problem yet, but I though this is something Apple would fix with GM.

  2. Tue 19 Aug 2014 04:26:08 PM CEST
    i4niac started the conversation Xcode 6 Beta 6 Swift can't handle long expressions.

    Hi all.
    I'm new to this forum and before I post my question just want to make sure that this is the right place to ask questions like "Things broken after Xcode 6 Beta 6 release!". I know there's developer forum, but this place looks much nicer :)
    Anyway, I'll go ahead and post this one, let me know if this does not belong here or something.

    I have a strange new error with beta 6, the error message is like

    .../Shared/Model/Rules.swift:310:9: Cannot invoke '&&' with an argument list of type '($T78, $T84)'
    .../Shared/Model/Rules.swift:310:9: Expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions

    The code in question is this:

    func ==(left: Rules, right: Rules) -> Bool {
        return left.numberOfPlayers == right.numberOfPlayers
                && left.numberOfCardsInDeck == right.numberOfCardsInDeck
                && left.pointSystem == right.pointSystem
                && left.numberOfCardsInHand == right.numberOfCardsInHand
                && left.cleanPoints == right.cleanPoints
                && left.playRobbers == right.playRobbers
                && left.maxPoints == right.maxPoints
                && left.canCallRoundEnd == right.canCallRoundEnd
                && left.canLayFaceDown == right.canLayFaceDown
                && left.callMolodkaAnyTime == right.callMolodkaAnyTime
                && left.buraWinsRound == right.buraWinsRound
                && left.moscowWinsRound == right.moscowWinsRound
                && left.numberOfCardsInMoscowCombo == right.numberOfCardsInMoscowCombo
                && left.bigMoscowRank == right.bigMoscowRan
                && left.smallMoscowRank == right.smallMoscowRank
    }

    As you can see, there's nothing special, just a lengthy piece of code.
    It works perfectly with beta 5, but with beta 6 I got an error.
    Suddenly Swift compiler got weaker and can't handle long expressions.
    I played around and commented some lines, in this example compiler will handle 10 lines nicely, and report an error on 11 or more.

    func ==(left: Rules, right: Rules) -> Bool {
        return left.numberOfPlayers == right.numberOfPlayers
                && left.numberOfCardsInDeck == right.numberOfCardsInDeck
                && left.pointSystem == right.pointSystem
                && left.numberOfCardsInHand == right.numberOfCardsInHand
                && left.cleanPoints == right.cleanPoints
                && left.playRobbers == right.playRobbers
                && left.maxPoints == right.maxPoints
                && left.canCallRoundEnd == right.canCallRoundEnd
                && left.canLayFaceDown == right.canLayFaceDown
                && left.callMolodkaAnyTime == right.callMolodkaAnyTime
    //            && left.buraWinsRound == right.buraWinsRound
    //            && left.moscowWinsRound == right.moscowWinsRound
    //            && left.numberOfCardsInMoscowCombo == right.numberOfCardsInMoscowCombo
    //            && left.bigMoscowRank == right.bigMoscowRan
    //            && left.smallMoscowRank == right.smallMoscowRank
    }

    Of course I can break it into couple of shorter expressions, but it looks like a bug to me so far.

  3. Tue 19 Aug 2014 04:19:39 PM CEST
    i4niac joined the forum.