Working on creating syntax debugging exercise for students. We have the following example.
def five():
print('five')
return 5
def hello();
print('hello')
However when running the file the syntax error is
def hello();
^
SyntaxError: invalid syntax
I've looked all over but can not figure out why the compiler [sic] doesn't complain about the return keyword outside of the function, but instead first finds the semicolon error under it.
In what order does Python check the file syntax? Is this part of the specification or is it implemenation defined?