@@ -202,14 +202,10 @@ impl<'a> SymbolTableAnalyzer<'a> {
202202 }
203203 let ( symbols, st_typ) = self . tables . pop ( ) . unwrap ( ) ;
204204
205- //println!("\n\n\n\n\nbefore analyze scope {:?} of type {:?}", symbols, st_typ.to_string());
206205 // Analyze symbols:
207206 for symbol in symbols. values_mut ( ) {
208207 self . analyze_symbol ( symbol, st_typ) ?;
209208 }
210-
211- //println!("\n\n\nafter analyze scope {:?} of type {:?}", symbols, st_typ.to_string());
212-
213209 Ok ( ( ) )
214210 }
215211
@@ -218,7 +214,6 @@ impl<'a> SymbolTableAnalyzer<'a> {
218214 symbol : & mut Symbol ,
219215 curr_st_typ : SymbolTableType ,
220216 ) -> SymbolTableResult {
221- //assert!(!symbol.is_assign_namedexpr_in_comprehension || curr_st_typ==SymbolTableType::Comprehension);
222217 if symbol. is_assign_namedexpr_in_comprehension
223218 && curr_st_typ == SymbolTableType :: Comprehension
224219 {
@@ -293,9 +288,6 @@ impl<'a> SymbolTableAnalyzer<'a> {
293288 parent_offset : usize ,
294289 ) -> SymbolTableResult {
295290 // when this is called, we expect to be in the direct parent scope of the scope that contains 'symbol'
296- //println!(" analyze symbol {:?}", symbol);
297-
298- //let mut last=self.tables.last_mut().unwrap();
299291 let offs = self . tables . len ( ) - 1 - parent_offset;
300292 let last = self . tables . get_mut ( offs) . unwrap ( ) ;
301293 let symbols = & mut last. 0 ;
@@ -306,18 +298,17 @@ impl<'a> SymbolTableAnalyzer<'a> {
306298 symbol. scope = SymbolScope :: Global ;
307299 }
308300 SymbolTableType :: Class => { }
309- SymbolTableType :: Function => match symbols . get_mut ( & symbol . name ) {
310- Some ( parent_symbol) => {
301+ SymbolTableType :: Function => {
302+ if let Some ( parent_symbol) = symbols . get_mut ( & symbol . name ) {
311303 match parent_symbol. scope {
312304 // possibly we can omit this check?
313305 SymbolScope :: Unknown => {
314- parent_symbol. is_assigned = true ; // this information is new, as it was
306+ parent_symbol. is_assigned = true ; // this information is new, as the asignment is done in inner scope
315307 self . analyze_unknown_symbol ( symbol) ;
316308 }
317309 _ => { }
318310 }
319311
320- println ! ( " symbol in parent scope contained" ) ;
321312 match symbol. scope {
322313 SymbolScope :: Global => {
323314 symbol. scope = SymbolScope :: Global ;
@@ -327,25 +318,13 @@ impl<'a> SymbolTableAnalyzer<'a> {
327318 }
328319 }
329320 }
330- None => {
331- //println!(" adding {:?} to next outer scope", symbol.name);
332- /*
333- //symbol.scope = SymbolScope::Nonlocal;
334- let mut sym_cloned = symbol.clone();
335- sym_cloned.scope=SymbolScope::Local;
336- symbol.scope = SymbolScope::Nonlocal;
337- last.0.insert(sym_cloned.name.to_owned(),sym_cloned);*/
338-
339- //assert!(false); // I guess this shall not happen, but if so we find it quickly to replace with proper handling
340- //println!("Found undefined symbol {:?} in scope {:?}", symbol.name, table_type.to_string());
341- }
342321 } ,
343322 SymbolTableType :: Comprehension => {
344323 // TODO check for conflicts
345324
346325 match symbols. get_mut ( & symbol. name ) {
347326 Some ( parent_symbol) => {
348- parent_symbol. is_assigned = true ; // more checks are reauired
327+ parent_symbol. is_assigned = true ; // more checks are required
349328 }
350329 None => {
351330 let cloned_sym = symbol. clone ( ) ;
0 commit comments