Check this case for Type Inference

I tried to write some example code in SICP book with swift.

For example,
(2 + (4 * 6)) * ((3 + 5) + 7)
If I write this code in REPL,
then it displayed the result of calculating - 370 after 10~11 sec.

And If I write this code in swift file,
It's compile error like that
error: the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
What happened to type-check or type-inference here? why this fail to compile?

Anyway this is a workaround solution.
Int(2 + (4 * 6)) * Int((3 + 5) + 7)

Please let me know, How do I guess this type inference?
How do I try to looking which type check process like this case?

The reason why this fails to compile is that the compiler needs to infer types for each of the literals and operators in that expression. Unlike other languages, Swift doesn't have a set type for literals, and the type of literals is inferred based on the context of where you use them. This causes type inference to take a lot longer in expressions with many chained operators and literals.

There are a few workarounds for this performance issue. First, like the error message suggests, you can break up the expression into several smaller ones, e.g.
Code Block
let a = (2 + (4 * 6))
let b = a * ((3 + 5) + 7)

Sometimes, adding an explicit type annotation to the variable you're assigning to will fix the issue
Code Block
let a: Int = (2 + (4 * 6)) * ((3 + 5) + 7)

But if that's not enough, you can also add explicit type annotations to subexpressions using the keyword as or by explicitly constructing the type that you want like you've done above to help the compiler figure out the types.


Check this case for Type Inference
 
 
Q