ability to examine declared functions for runtime checks
gfogle opened this issue · 3 comments
one of the main selling points of flow is that it can examine your functions - so to speak - to make sure your function always returns a value etc to eliminate runtime exceptions
ideally we should be able to do this.
I think this issue is basically this #9 right? Or is it a little more involved?
At the moment the checker does two checks; it checks variable declarations (i.e. var n /* t:number */ = 'asdf'
and function declarations on the root scope and then follows the rabbit hole. For example, this error is caught:
function d(x /* t:string */) /* t:string */ {
function e(y /* t:string */) /* t:string */ {
function f(z /* t:string */) /* t:number */ {
return y + x + z;
}
return f(y);
}
return e(x);
}
Am I misunderstanding or are you basically saying that we should check for undefined/null variables?
i think #9 might be it then. We just want to make sure that the following errors for this function are caught:
function (e /* t:int */) /* t: int */ {
if (e > 2 && e < 5) {
return e + 2;
} else if (e >= 5) {
return 'a string?';
}
}
in the case where e < 2 nothing will be returned, and in the case where e >=5 a string is returned instead of a number.
maybe i misunderstood #9 its description is a little verbose
Oh, I see what you're saying, I think #9 only partially covers this
situation, I.e. the returning undefined one. This issue is still valid for
the "could be a string could be a number" situation though.
On Sun, Sep 18, 2016, 10:19 AM George Fogle notifications@github.com
wrote:
i think #9 #9 might be it then.
We just want to make sure that the following errors for this function are
caught:function (e /* t:int /) / t: int */ {
if (e > 2 && e < 5) {
return e + 2;
} else if (e >= 5) {
return 'a string?';
}
}in the case where e < 2 nothing will be returned, and in the case where e
=5 a string is returned instead of a number.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#13 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABNnLccLCPn5BlDVyzfmW25DjCiEkvH0ks5qrUh_gaJpZM4J_yyS
.