nohtyprm / MrPython

A simplified programming environment for Python (3.x) - based on IDLE
https://nohtyprm.github.io/MrPython/
Other
28 stars 34 forks source link

No assigning returning variable result in a tkinter error #98

Closed matthiasbe closed 4 years ago

matthiasbe commented 4 years ago

Hello,

with the following code

def sablier(x0,y0):
    """Number*Number -> NoneType"""

    draw_triangle(x0, y0, x0+1, y0+1, x0+1, y0)

Run program never stops, I have to stop it through the "hand" button.

Terminal exception:

Exception in Tkinter callback

Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 1705, in __call__
    return self.func(*args)
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 749, in callit
    func(*args)
  File "/Users/mbeauper/enseignement/LU1IN001/MrPython/mrpython/PyInterpreter.py", line 45, in timer_callback
    ok, report = self.comm.recv()
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/connection.py", line 250, in recv
    buf = self._recv_bytes()
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/connection.py", line 407, in _recv_bytes
    buf = self._recv(4)
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/connection.py", line 383, in _recv
    raise EOFError
EOFError
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 1705, in __call__
    return self.func(*args)
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 749, in callit
    func(*args)
  File "/Users/mbeauper/enseignement/LU1IN001/MrPython/mrpython/PyInterpreter.py", line 75, in run_loop
    ok, report = interp.execute()
  File "/Users/mbeauper/enseignement/LU1IN001/MrPython/mrpython/PyInterpreter.py", line 143, in execute
    ok = runner.execute(self.locals)
  File "/Users/mbeauper/enseignement/LU1IN001/MrPython/mrpython/StudentRunner.py", line 81, in execute
    if not self.check_rules(self.report):
  File "/Users/mbeauper/enseignement/LU1IN001/MrPython/mrpython/StudentRunner.py", line 198, in check_rules
    if not self.check_types():
  File "/Users/mbeauper/enseignement/LU1IN001/MrPython/mrpython/StudentRunner.py", line 243, in check_types
    type_ctx = typecheck_from_ast(self.AST, self.filename, self.source)
  File "/Users/mbeauper/enseignement/LU1IN001/MrPython/mrpython/typechecking/typechecker.py", line 2867, in typecheck_from_ast
    ctx = prog.type_check()
  File "/Users/mbeauper/enseignement/LU1IN001/MrPython/mrpython/typechecking/typechecker.py", line 273, in type_check_Program
    fun_def.type_check(ctx)
  File "/Users/mbeauper/enseignement/LU1IN001/MrPython/mrpython/typechecking/typechecker.py", line 328, in type_check_FunctionDef
    instr.type_check(ctx)
  File "/Users/mbeauper/enseignement/LU1IN001/MrPython/mrpython/typechecking/typechecker.py", line 721, in type_check_ECall
    ctx.add_type_error(CallNotNoneError(enode, call_type))
NameError: name 'CallNotNoneError' is not defined

Following code works properly

def sablier(x0,y0):
    """Number*Number -> Image"""

    return draw_triangle(x0, y0, x0+1, y0+1, x0+1, y0)

This one also works

def sablier(x0,y0):
    """Number*Number -> NoneType"""

    # i : Image
    i = draw_triangle(x0, y0, x0+1, y0+1, x0+1, y0)
fredokun commented 4 years ago

This is solved by commit https://github.com/nohtyprm/MrPython/commit/2d06f0723849a645b920cc25422e82537d088fed