File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1912,7 +1912,9 @@ impl<O: OutputStream> Compiler<O> {
19121912 fn lookup_name ( & self , name : & str ) -> & Symbol {
19131913 // println!("Looking up {:?}", name);
19141914 let scope = self . scope_stack . last ( ) . unwrap ( ) ;
1915- scope. lookup ( name) . unwrap ( )
1915+ scope. lookup ( name) . expect (
1916+ "The symbol must be present in the symbol table, even when it is undefined in python." ,
1917+ )
19161918 }
19171919
19181920 // Low level helper functions:
Original file line number Diff line number Diff line change @@ -244,13 +244,11 @@ impl SymbolTableBuilder {
244244 } => {
245245 self . scan_expressions ( decorator_list) ?;
246246 self . register_name ( name, SymbolRole :: Assigned ) ?;
247-
248- self . enter_function ( args) ?;
249-
250- self . scan_statements ( body) ?;
251247 if let Some ( expression) = returns {
252248 self . scan_expression ( expression) ?;
253249 }
250+ self . enter_function ( args) ?;
251+ self . scan_statements ( body) ?;
254252 self . leave_scope ( ) ;
255253 }
256254 ClassDef {
Original file line number Diff line number Diff line change 1-
21__name__ = "function"
32
43
@@ -72,3 +71,20 @@ def nested():
7271
7372
7473f6 ()
74+
75+
76+ def f7 ():
77+ try :
78+ def t () -> void : # noqa: F821
79+ pass
80+ except NameError :
81+ return True
82+ return False
83+
84+ assert f7 ()
85+
86+
87+ def f8 () -> int :
88+ return 10
89+
90+ assert f8 () == 10
You can’t perform that action at this time.
0 commit comments