Skip to content

Commit

Permalink
apply bts suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Jan 15, 2024
1 parent e7b029b commit 0c0f4ae
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
3 changes: 0 additions & 3 deletions vyper/semantics/analysis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,9 +648,6 @@ def check_modifiability(node: vy_ast.VyperNode, modifiability: Modifiability) ->
call_type = get_exact_type_from_node(node.func)

# structs and interfaces
if isinstance(call_type, TYPE_T):
call_type = call_type.typedef

if hasattr(call_type, "check_modifiability_for_call"):
return call_type.check_modifiability_for_call(node, modifiability)

Expand Down
5 changes: 5 additions & 0 deletions vyper/semantics/types/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ def __init__(self, typedef):
def __repr__(self):
return f"type({self.typedef})"

def check_modifiability_for_call(self, node, modifiability):
if hasattr(self.typedef, "_ctor_modifiability_for_call"):
return self.typedef._ctor_modifiability_for_call(node, modifiability)
raise StructureException("Value is not callable", node)

# dispatch into ctor if it's called
def fetch_call_return(self, node):
if hasattr(self.typedef, "_ctor_call_return"):
Expand Down
2 changes: 1 addition & 1 deletion vyper/semantics/types/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _ctor_arg_types(self, node):
def _ctor_kwarg_types(self, node):
return {}

def check_modifiability_for_call(self, node: vy_ast.Call, modifiability: Modifiability) -> bool:
def _ctor_modifiability_for_call(self, node: vy_ast.Call, modifiability: Modifiability) -> bool:
return check_modifiability(node.args[0], modifiability)

# TODO x.validate_implements(other)
Expand Down
2 changes: 1 addition & 1 deletion vyper/semantics/types/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,5 +421,5 @@ def _ctor_call_return(self, node: vy_ast.Call) -> "StructT":

return self

def check_modifiability_for_call(self, node: vy_ast.Call, modifiability: Modifiability) -> bool:
def _ctor_modifiability_for_call(self, node: vy_ast.Call, modifiability: Modifiability) -> bool:
return all(check_modifiability(v, modifiability) for v in node.args[0].values)

0 comments on commit 0c0f4ae

Please sign in to comment.