File tree Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -1912,7 +1912,9 @@ impl<O: OutputStream> Compiler<O> {
1912
1912
fn lookup_name ( & self , name : & str ) -> & Symbol {
1913
1913
// println!("Looking up {:?}", name);
1914
1914
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
+ )
1916
1918
}
1917
1919
1918
1920
// Low level helper functions:
Original file line number Diff line number Diff line change @@ -244,13 +244,11 @@ impl SymbolTableBuilder {
244
244
} => {
245
245
self . scan_expressions ( decorator_list) ?;
246
246
self . register_name ( name, SymbolRole :: Assigned ) ?;
247
-
248
- self . enter_function ( args) ?;
249
-
250
- self . scan_statements ( body) ?;
251
247
if let Some ( expression) = returns {
252
248
self . scan_expression ( expression) ?;
253
249
}
250
+ self . enter_function ( args) ?;
251
+ self . scan_statements ( body) ?;
254
252
self . leave_scope ( ) ;
255
253
}
256
254
ClassDef {
Original file line number Diff line number Diff line change 1
-
2
1
__name__ = "function"
3
2
4
3
@@ -72,3 +71,20 @@ def nested():
72
71
73
72
74
73
f6 ()
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