@@ -11,7 +11,7 @@ use crate::{
1111 IndexMap , IndexSet , ToPythonName ,
1212 error:: { CodegenError , CodegenErrorType , PatternUnreachableReason } ,
1313 ir:: { self , BlockIdx } ,
14- symboltable:: { self , SymbolFlags , SymbolScope , SymbolTable , SymbolTableType } ,
14+ symboltable:: { self , CompilerScope , SymbolFlags , SymbolScope , SymbolTable } ,
1515 unparse:: unparse_expr,
1616} ;
1717
@@ -409,7 +409,7 @@ impl Compiler<'_> {
409409 fn enter_scope (
410410 & mut self ,
411411 name : & str ,
412- scope_type : SymbolTableType ,
412+ scope_type : CompilerScope ,
413413 key : usize , // In RustPython, we use the index in symbol_table_stack as key
414414 lineno : u32 ,
415415 ) -> CompileResult < ( ) > {
@@ -452,14 +452,14 @@ impl Compiler<'_> {
452452 // Handle implicit __class__ cell if needed
453453 if ste. needs_class_closure {
454454 // Cook up an implicit __class__ cell
455- debug_assert_eq ! ( scope_type, SymbolTableType :: Class ) ;
455+ debug_assert_eq ! ( scope_type, CompilerScope :: Class ) ;
456456 cellvar_cache. insert ( "__class__" . to_string ( ) ) ;
457457 }
458458
459459 // Handle implicit __classdict__ cell if needed
460460 if ste. needs_classdict {
461461 // Cook up an implicit __classdict__ cell
462- debug_assert_eq ! ( scope_type, SymbolTableType :: Class ) ;
462+ debug_assert_eq ! ( scope_type, CompilerScope :: Class ) ;
463463 cellvar_cache. insert ( "__classdict__" . to_string ( ) ) ;
464464 }
465465
@@ -480,21 +480,21 @@ impl Compiler<'_> {
480480
481481 // Initialize u_metadata fields
482482 let ( flags, posonlyarg_count, arg_count, kwonlyarg_count) = match scope_type {
483- SymbolTableType :: Module => ( bytecode:: CodeFlags :: empty ( ) , 0 , 0 , 0 ) ,
484- SymbolTableType :: Class => ( bytecode:: CodeFlags :: empty ( ) , 0 , 0 , 0 ) ,
485- SymbolTableType :: Function | SymbolTableType :: Lambda => (
483+ CompilerScope :: Module => ( bytecode:: CodeFlags :: empty ( ) , 0 , 0 , 0 ) ,
484+ CompilerScope :: Class => ( bytecode:: CodeFlags :: empty ( ) , 0 , 0 , 0 ) ,
485+ CompilerScope :: Function | CompilerScope :: AsyncFunction | CompilerScope :: Lambda => (
486486 bytecode:: CodeFlags :: NEW_LOCALS | bytecode:: CodeFlags :: IS_OPTIMIZED ,
487487 0 , // Will be set later in enter_function
488488 0 , // Will be set later in enter_function
489489 0 , // Will be set later in enter_function
490490 ) ,
491- SymbolTableType :: Comprehension => (
491+ CompilerScope :: Comprehension => (
492492 bytecode:: CodeFlags :: NEW_LOCALS | bytecode:: CodeFlags :: IS_OPTIMIZED ,
493493 0 ,
494494 1 , // comprehensions take one argument (.0)
495495 0 ,
496496 ) ,
497- SymbolTableType :: TypeParams => (
497+ CompilerScope :: TypeParams => (
498498 bytecode:: CodeFlags :: NEW_LOCALS | bytecode:: CodeFlags :: IS_OPTIMIZED ,
499499 0 ,
500500 0 ,
@@ -530,7 +530,7 @@ impl Compiler<'_> {
530530 kwonlyargcount : kwonlyarg_count,
531531 firstlineno : OneIndexed :: new ( lineno as usize ) . unwrap_or ( OneIndexed :: MIN ) ,
532532 } ,
533- static_attributes : if scope_type == SymbolTableType :: Class {
533+ static_attributes : if scope_type == CompilerScope :: Class {
534534 Some ( IndexSet :: default ( ) )
535535 } else {
536536 None
@@ -544,12 +544,12 @@ impl Compiler<'_> {
544544 self . code_stack . push ( code_info) ;
545545
546546 // Set qualname after pushing (uses compiler_set_qualname logic)
547- if scope_type != SymbolTableType :: Module {
547+ if scope_type != CompilerScope :: Module {
548548 self . set_qualname ( ) ;
549549 }
550550
551551 // Emit RESUME instruction
552- let _resume_loc = if scope_type == SymbolTableType :: Module {
552+ let _resume_loc = if scope_type == CompilerScope :: Module {
553553 // Module scope starts with lineno 0
554554 ruff_source_file:: SourceLocation {
555555 row : OneIndexed :: MIN ,
@@ -569,7 +569,7 @@ impl Compiler<'_> {
569569 }
570570 ) ;
571571
572- if scope_type == SymbolTableType :: Module {
572+ if scope_type == CompilerScope :: Module {
573573 // This would be loc.lineno = -1 in CPython
574574 // We handle this differently in RustPython
575575 }
@@ -950,11 +950,7 @@ impl Compiler<'_> {
950950 cache = & mut info. metadata . cellvars ;
951951 NameOpType :: Deref
952952 } // TODO: is this right?
953- SymbolScope :: TypeParams => {
954- // Type parameters are always cell variables
955- cache = & mut info. metadata . cellvars ;
956- NameOpType :: Deref
957- } // SymbolScope::Unknown => NameOpType::Global,
953+ // SymbolScope::Unknown => NameOpType::Global,
958954 } ;
959955
960956 if NameUsage :: Load == usage && name == "__debug__" {
@@ -1999,7 +1995,7 @@ impl Compiler<'_> {
19991995 let table = self . symbol_table_stack . last ( ) . unwrap ( ) ;
20001996 match table. lookup ( name) {
20011997 Some ( symbol) => match symbol. scope {
2002- SymbolScope :: Cell | SymbolScope :: TypeParams => Ok ( SymbolScope :: Cell ) ,
1998+ SymbolScope :: Cell => Ok ( SymbolScope :: Cell ) ,
20031999 SymbolScope :: Free => Ok ( SymbolScope :: Free ) ,
20042000 _ if symbol. flags . contains ( SymbolFlags :: FREE_CLASS ) => Ok ( SymbolScope :: Free ) ,
20052001 _ => Err ( CodegenErrorType :: SyntaxError ( format ! (
@@ -2204,7 +2200,7 @@ impl Compiler<'_> {
22042200 // Use enter_scope instead of push_output to match CPython
22052201 let key = self . symbol_table_stack . len ( ) ;
22062202 self . push_symbol_table ( ) ;
2207- self . enter_scope ( name, SymbolTableType :: Class , key, firstlineno) ?;
2203+ self . enter_scope ( name, CompilerScope :: Class , key, firstlineno) ?;
22082204
22092205 // Set qualname using the new method
22102206 let qualname = self . set_qualname ( ) ;
0 commit comments