|
|
|
|
|
by dmurray
739 days ago
|
|
> The issue is caused by using the + operator with the channel Int and a String literal. Thanks to the standard library’s 17 overloads of + and 9 types adopting the ExpressibleByStringLiteral Protocol, the swift compiler can’t rule out that there might be a combination of types and operators that make the expression valid, so it has to try them all. Just considering that the five string literals could be one of the possible nine types results in 59,049 combinations, but I suspect that’s a lower bound, since it doesn’t consider the many overloads of +. This really seems like a design flaw. If there are 59,049 overloads for string concatenation, surely either - one of them should be expressive enough to allow concatenation with an integer, which we can do after all in some other languages - or, the type system should have some way to express that no type reachable by concatenating subtypes of String can ever get concatenated to an integer. Is this unreasonable? Probably there's some theorem about why I'm wrong. |
|