-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Labels
todo (pstl)special label for student projectsspecial label for student projects
Description
For example take the following function:
def func(a:int) -> int:
"""
Renvoie un nombre positif tel quel
Precondition: a>=0
"""
return a
assert func(1)==1
assert func(-1)==-1
Executing it will show the following error:
-----
Erreurs à l'exécution (Interprète Python) :
-----
Erreur: ligne 9
==> Erreur de précondition
Fonction : func (Ligne 4)
Précondition : a>=0
Fausse avec
a = -1
===================================================
But running func(-1) in the interactive interpreter keeps on forever without any messages and I have to manually stop the execution.
EDIT:
This issue also occurs whenever the precondition fails when calling the function inside another function WHICH HAS PRECONDITIONS.
For example add this function to the script:
def func_1(a:int) -> int:
"""
Renvoie un nombre positif tel quel
Precondition: a>=-1
"""
return func(a)
assert func_1(-1)==-1
It will run forever but if we changed it to remove preconditions:
def func_1(a:int) -> int:
"""
Renvoie un nombre positif tel quel
Precondition:
"""
return func(a)
assert func_1(-1)==-1
It now shows the appropriate error:
-----
Erreurs à l'exécution (Interprète Python) :
-----
Erreur: ligne 16
==> Erreur de précondition
Fonction : func (Ligne 4)
Précondition : a>=0
Fausse avec
a = a
===================================================
Note: The last error message could be more informative than a=a
Metadata
Metadata
Assignees
Labels
todo (pstl)special label for student projectsspecial label for student projects