File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -616,7 +616,18 @@ impl Compiler<'_> {
616
616
// compiler_exit_scope
617
617
fn exit_scope ( & mut self ) -> CodeObject {
618
618
let table = self . pop_symbol_table ( ) ;
619
- assert ! ( table. sub_tables. is_empty( ) ) ;
619
+
620
+ // TypeParams scope can have sub_tables (the function body's symbol table)
621
+ // This matches CPython's behavior where type params scope contains the function scope
622
+ if table. typ != CompilerScope :: TypeParams {
623
+ assert ! (
624
+ table. sub_tables. is_empty( ) ,
625
+ "Only TypeParams scope can have sub_tables, but {:?} has {} sub_tables" ,
626
+ table. typ,
627
+ table. sub_tables. len( )
628
+ ) ;
629
+ }
630
+
620
631
let pop = self . code_stack . pop ( ) ;
621
632
let stack_top = compiler_unwrap_option ( self , pop) ;
622
633
unwrap_internal ( self , stack_top. finalize_code ( self . opts . optimize ) )
You can’t perform that action at this time.
0 commit comments