Infinite loop detection
goodmind opened this issue · comments
Where should I add something like this?
TypeScript:
function hello(): never { // ok
while(true) {}
}
Flow:
function hello(): empty { // error, void is incompatible with empty
while(true) {}
}
Something's not right with these examples, @goodmind. An empty function returns void
, not empty
, so you'll get exactly the same error regardless the function's contents. Example.
I don't think the TypeScript example is right either. The meaning of never
is actually that the function will never return - which is exactly what would happen. So even if TS had infinite loop protection, the result of hello
should be never
rather than void
. In fact, if you do the opposite, TS complains.
Not empty functions, with while(true)
loop
Ah, I see. Yeah, I think it makes sense to add this. Perhaps a new section on behavior differences, since this is not syntax-specific? Thanks!