You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* @flow */
function f(x: number): number {
var y;
if (x < 0) {
throw new Error();
} else {
y = Math.sqrt(x);
}
return y;
}
then Flow complains that y (undefined) is incompatible with number because it doesn't get properly initialized. If you add y = 0; on the line after the throw then no errors are thrown – ideally Flow would recognize the semantics of the throw statement here and know that the return statement isn't reached in the case that an error is thrown.
The text was updated successfully, but these errors were encountered:
If I have code like the following
then Flow complains that
y
(undefined) is incompatible withnumber
because it doesn't get properly initialized. If you addy = 0;
on the line after thethrow
then no errors are thrown – ideally Flow would recognize the semantics of the throw statement here and know that the return statement isn't reached in the case that an error is thrown.The text was updated successfully, but these errors were encountered: