Skip to content

Commit

Permalink
change is_not_initializable to is_initializable
Browse files Browse the repository at this point in the history
  • Loading branch information
sandbubbles committed Dec 12, 2024
1 parent 7b2f38b commit bb4944f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion vyper/semantics/analysis/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def visit_InitializesDecl(self, node):
module_info = get_expr_info(module_ref).module_info
if module_info is None:
raise StructureException("Not a module!", module_ref)
if module_info.module_t.is_not_initializable:
if not module_info.module_t.is_initializable:
raise StructureException(
f"Cannot initialize a stateless module {module_info.alias}!", module_ref
)
Expand Down
14 changes: 7 additions & 7 deletions vyper/semantics/types/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,22 +561,22 @@ def interface(self):
return InterfaceT.from_ModuleT(self)

@cached_property
def is_not_initializable(self):
def is_initializable(self):
"""
Determine whether ModuleT is stateless by examining its top-level
Determine whether ModuleT can be initialised by examining its top-level
declarations. A module has state if it contains storage variables,
transient variables, or immutables, or if it includes a "initializes"
declaration, or any nonreentrancy locks.
"""
if len(self.initializes_decls) > 0:
return False
return True
if any(not v.is_constant for v in self.variable_decls):
return False
return True
if self.init_function is not None:
return False
return True

for fun in self.functions.values():
if fun.nonreentrant:
return False
return True

return True
return False

0 comments on commit bb4944f

Please sign in to comment.