Skip to content

Commit 3f5eaa5

Browse files
committed
reinstantiate builtins
1 parent bcbf8d3 commit 3f5eaa5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

vyper/builtins/functions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,6 +2738,16 @@ def _try_fold(self, node):
27382738

27392739
BUILTIN_FUNCTIONS = {**STMT_DISPATCH_TABLE, **DISPATCH_TABLE}.keys()
27402740

2741+
# reset the state of the builtins
2742+
# so that attributes like `_warned` don't persist across runs
2743+
def reinstantiate_builtins():
2744+
for t in [DISPATCH_TABLE, STMT_DISPATCH_TABLE]:
2745+
for k, v in t.items():
2746+
new_instance = type(v)()
2747+
t[k] = new_instance
2748+
global BUILTIN_FUNCTIONS
2749+
BUILTIN_FUNCTIONS = {**DISPATCH_TABLE, **STMT_DISPATCH_TABLE}.keys()
2750+
27412751

27422752
def get_builtin_functions():
27432753
return {**STMT_DISPATCH_TABLE, **DISPATCH_TABLE}

vyper/compiler/phases.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import vyper.codegen.core as codegen
88
from vyper import ast as vy_ast
99
from vyper.ast import natspec
10+
from vyper.builtins import functions as builtins
1011
from vyper.codegen import module
1112
from vyper.codegen.ir_node import IRnode
1213
from vyper.compiler.input_bundle import FileInput, FilesystemInputBundle, InputBundle
@@ -115,6 +116,7 @@ def contract_path(self):
115116

116117
@cached_property
117118
def _generate_ast(self):
119+
builtins.reinstantiate_builtins()
118120
is_vyi = self.contract_path.suffix == ".vyi"
119121

120122
settings, ast = vy_ast.parse_to_ast_with_settings(

0 commit comments

Comments
 (0)