@@ -665,11 +665,18 @@ async def call(self, ast_ctx, *args, **kwargs):
665
665
# switch to the global symbol table in the global context
666
666
# where the function was defined
667
667
#
668
- prev_sym_table = [ast_ctx .global_sym_table , ast_ctx .sym_table , ast_ctx .sym_table_stack ]
668
+ prev_sym_table = [
669
+ ast_ctx .global_sym_table ,
670
+ ast_ctx .sym_table ,
671
+ ast_ctx .sym_table_stack ,
672
+ ast_ctx .global_ctx ,
673
+ ]
669
674
ast_ctx .global_sym_table = self .global_ctx .get_global_sym_table ()
670
675
ast_ctx .sym_table_stack = [ast_ctx .global_sym_table ]
676
+ ast_ctx .global_ctx = self .global_ctx
671
677
else :
672
678
ast_ctx .sym_table_stack .append (ast_ctx .sym_table )
679
+ prev_sym_table = None
673
680
ast_ctx .sym_table = sym_table
674
681
code_str , code_list = ast_ctx .code_str , ast_ctx .code_list
675
682
ast_ctx .code_str , ast_ctx .code_list = self .code_str , self .code_list
@@ -689,8 +696,13 @@ async def call(self, ast_ctx, *args, **kwargs):
689
696
break
690
697
ast_ctx .curr_func = prev_func
691
698
ast_ctx .code_str , ast_ctx .code_list = code_str , code_list
692
- if ast_ctx .global_ctx != self .global_ctx :
693
- ast_ctx .global_sym_table , ast_ctx .sym_table , ast_ctx .sym_table_stack = prev_sym_table
699
+ if prev_sym_table is not None :
700
+ (
701
+ ast_ctx .global_sym_table ,
702
+ ast_ctx .sym_table ,
703
+ ast_ctx .sym_table_stack ,
704
+ ast_ctx .global_ctx ,
705
+ ) = prev_sym_table
694
706
else :
695
707
ast_ctx .sym_table = ast_ctx .sym_table_stack .pop ()
696
708
return val
0 commit comments