Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop detection #56

Open
goodmind opened this issue Jun 4, 2019 · 4 comments
Open

Infinite loop detection #56

goodmind opened this issue Jun 4, 2019 · 4 comments

Comments

@goodmind
Copy link

goodmind commented Jun 4, 2019

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) {}
}
@niieani
Copy link
Owner

niieani commented Jun 4, 2019

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.

@goodmind
Copy link
Author

goodmind commented Jun 5, 2019

Not empty functions, with while(true) loop

@goodmind
Copy link
Author

goodmind commented Jun 5, 2019

Flow

TS

TS is right here, because this function never returns, not returns void. I'm asking where should I add this comparison in README

@niieani
Copy link
Owner

niieani commented Jun 5, 2019

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants