Aug. 31, 2016
7:52 a.m.
On 31 August 2016 at 13:09, Nick Coghlan <ncoghlan@gmail.com> wrote:
I guess as long as they're included somewhere in the AST for the function body, I don't mind if the translation to bytecode throws them away - that's essentially saying that a function level type annotation is effectively interpreted as if it was:
if False: __annotations__[<varname>] = <annotation>
So the code generator will pick up syntax errors during normal execution, but not runtime errors (since the expression never actually gets evaluated).
Nick, you are right, in current implementation they are included in AST in exactly the same way as in classes and modules, but compiler throws them away. -- Ivan