-
Notifications
You must be signed in to change notification settings - Fork 38
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
Functions without a return statement always type-check #57
Comments
It's not that simple ... because I cannot be sure that the last instruction will be a "return None" because it's potential dead code ... I think I can still give a type error for non-NoneType functions when I do not encounter any return (but I cannot be 100% precise without a control-flow analysis...). |
A solution that is "acceptable", I think, has been push in commit c72b9e1 |
This is better but there are still some unhandled cases def f(x):
""" int -> int """
if x > 5:
return x Moreover, I guess you forgot to remove some debugging
|
I concur. In this (nonsensical) code from a student, I noticed that when there is no unconditional return at the end, the ill-typed assignment def eval_chiffres(L):
"""list[int]->int"""
if len(L)==0:
return 0
else:
#res:int
res=0
#x:int
x=L[0]
#i:int
for i in L:
#j:int
for j in L:
if i>x:
i=L[0]
res=L[i:j]
return res |
The result of this function has type
NoneType
and notint
(Mr Python version 06786b5)
The text was updated successfully, but these errors were encountered: