Hacker News new | ask | show | jobs
by tantalor 740 days ago
> they’re invalid swift

If this isn't valid why are we even taking about it? The compiler should report syntax error or something

3 comments

The point is that it's valid syntax (invalid syntax is found in an earlier phase of compilation and would report much faster). It's invalid in Swift's type system, and it takes it 42 seconds (in the string example) and 8 seconds (in the math expression one) for it to tell you that it can't type-check it in a reasonable time and then it quits.
"Reasonable time" is subjective. What happens if you don't limit the time?

Guesses:

1. Successfully compiles

2. Reports an error

3. Never halts

4. Nobody knows

That’s the point. It’s invalid swift syntax, but it takes >40 seconds to tell you that.
If there was just the right overload hiding somewhere, it wouldn't be an error and it would take a similar amount of time. This is just the easiest way to show off the problem, which is how long it takes to check.