Too complex to compile after update to Xcode 14.3.1

Too Complex to Compile?

Ventura 13.4.1

New error after update to Xcode 14.3.1 from 14.3.0

// ... <= -(roomHeight/2 - kFudge) too complex to compile ??
if (playerPosY - playerHeight/2) <= (kFudge - roomHeight/2)
{
// ... this variation works, the previous one doesn't
}

kFudge and the other parms are declared Double! within AppDelegate.

I don't understand what is suddenly wrong after Xcode update.

Answered by JohnLove in 757053022

Claude, I am going to go just with (2) because it works and less typing than (1). Certainly less than your Double(2) recommendation.

All this still seems a little like “black magic” = “try this .. try that .. try something else“.

SO it’s back to SKTextures and other game-stuff.

Claude, I cannot possibly thank you enough for your sticking with me. 5 smiley faces for you.

Are playerPosY and playerHeight Double or CGFloat ?

Is it UIKit or SwiftUI (which is much less tolerant for this) ?

Does this compile ?

if Double(playerPosY - playerHeight/2) <= -(roomHeight/2 - kFudge)

(1) playerPosY and playerHeight are = Double

(2) SwiftUI ( I think? But, I do call import SpriteKit, GameController, + QuartzCore for various other needs )

(3) if Double(playerPosY - playerHeight/2) <= -(roomHeight/2 - kFudge) DOES! compile

(4) I gotta say all this is very mysterious to me

SwiftUI does a lot of type inference when evaluating an expression, which may lead to this type of compiler issue where there is no obvious reason.

And the order of expression evaluation does matter, which could explain the difference between the 2 formulations.

However, it is nor clear in your original post, which works and which fails:

// ... <= -(roomHeight/2 - kFudge) too complex to compile ??
if (playerPosY - playerHeight/2) <= (kFudge - roomHeight/2)
{
// ... this variation works, the previous one doesn't
}

Could you try to replace 2 by Double(2) in the one that fails ?:

(1) if Double(playerPosY - playerHeight/2) <= -(roomHeight/2 - kFudge)

WORKS

=====

(2) if (playerPosY - playerHeight/2) <= (kFudge - roomHeight/2)

WORKS

=====

(3) if (playerPosY - playerHeight/2) <= -(roomHeight/2 - kFudge)

FAIL

=====

All Parms are declared Double, SO

Double - Double = a Double

SO, why doesn’t 3 work??

SO, why doesn’t 3 work??

Probably because the - sign introduces an extra level of type chacking which overpasses compiler capability.

Did you try what I proposed, just to check ?

if (playerPosY - playerHeight / Double(2)) <= -(roomHeight / Double(2) - kFudge)
Accepted Answer

Claude, I am going to go just with (2) because it works and less typing than (1). Certainly less than your Double(2) recommendation.

All this still seems a little like “black magic” = “try this .. try that .. try something else“.

SO it’s back to SKTextures and other game-stuff.

Claude, I cannot possibly thank you enough for your sticking with me. 5 smiley faces for you.

OK,

This WORKS

if (playerPosY - playerHeight/2) <= -(roomHeight/2.0 - kFudge)
{
}

NOT

if (playerPosY - playerHeight/2) <= -(roomHeight/2 - kFudge)
{
}

BUT, THIS WORKS

if false
{
}
else if (playerPosY - playerHeight/2) <= -(roomHeight/2 - kFudge)
{
}

NOW, I hope you are screaming like I am ... Misery Loves Company

It would be interesting to post a bug report.

But once again, that is probably by how SwiftUI performs type inference.

Does this work (I would not be surprised)?

if (playerPosY - playerHeight/2)  + (roomHeight/2 - kFudge) <= 0 {
}

This being said, you're right ; SwiftUI is nightmarish on this (and a feww other error messages).

You’re a Saint for sticking this out

Error happens when

-(a-b)

but not

(b-a)

WHEN /2

NO Error anywhere when /2.0

Go Figure

Too complex to compile after update to Xcode 14.3.1
 
 
Q