From dbd85e202b3402f344b8c698d532b28511cf293c Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Tue, 25 Jul 2023 14:59:47 +0800 Subject: [PATCH] wip --- vyper/semantics/analysis/local.py | 10 +++++----- vyper/semantics/analysis/module.py | 2 +- vyper/semantics/types/function.py | 4 ---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/vyper/semantics/analysis/local.py b/vyper/semantics/analysis/local.py index 9071bbeb2f..1724011f71 100644 --- a/vyper/semantics/analysis/local.py +++ b/vyper/semantics/analysis/local.py @@ -578,10 +578,6 @@ def visit_Return(self, node): f"expected {self.func.return_type.length}, got {len(values)}", node, ) - for given, expected in zip(values, self.func.return_type.member_types): - validate_expected_type(given, expected) - else: - validate_expected_type(values, self.func.return_type) self.expr_visitor.visit(node.value, self.func.return_type) @@ -715,6 +711,7 @@ def visit_Call(self, node: vy_ast.Call, typ: Optional[VyperType] = None) -> None #self.visit(node.func, call_type) if isinstance(call_type, ContractFunctionT): + node._metadata["type"] = call_type.fetch_call_return(node) # function calls if call_type.is_internal: self.func.called_functions.add(call_type) @@ -748,7 +745,6 @@ def visit_Call(self, node: vy_ast.Call, typ: Optional[VyperType] = None) -> None for arg, arg_type in zip(node.args, call_type.arg_types): self.visit(arg, arg_type) else: - node._metadata["type"] = call_type.fetch_call_return(node) # builtin functions arg_types = call_type.infer_arg_types(node) # `infer_arg_types` already calls `validate_expected_type` @@ -758,6 +754,8 @@ def visit_Call(self, node: vy_ast.Call, typ: Optional[VyperType] = None) -> None for kwarg in node.keywords: self.visit(kwarg.value, kwarg_types[kwarg.arg]) + node._metadata["type"] = call_type.fetch_call_return(node) + def visit_Compare(self, node: vy_ast.Compare, typ: Optional[VyperType] = None) -> None: if isinstance(node.op, (vy_ast.In, vy_ast.NotIn)): # membership in list literal - `x in [a, b, c]` @@ -892,6 +890,8 @@ def visit_List(self, node: vy_ast.List, typ: Optional[VyperType] = None) -> None derived_typ = sarray_t elif typ and typ.compare_type(darray_t): derived_typ = darray_t + else: + derived_typ = darray_t node._metadata["type"] = derived_typ diff --git a/vyper/semantics/analysis/module.py b/vyper/semantics/analysis/module.py index d916dcf119..de7726dc94 100644 --- a/vyper/semantics/analysis/module.py +++ b/vyper/semantics/analysis/module.py @@ -247,7 +247,7 @@ def _validate_self_namespace(): if not check_constant(node.value): raise StateAccessViolation("Value must be a literal", node.value) - validate_expected_type(node.value, type_) + #validate_expected_type(node.value, type_) _validate_self_namespace() return _finalize() diff --git a/vyper/semantics/types/function.py b/vyper/semantics/types/function.py index 10711edc8e..b995260f6b 100644 --- a/vyper/semantics/types/function.py +++ b/vyper/semantics/types/function.py @@ -499,9 +499,6 @@ def fetch_call_return(self, node: vy_ast.Call) -> Optional[VyperType]: if kwarg_node is not None: raise CallViolation("Cannot send ether to nonpayable function", kwarg_node) - for arg, expected in zip(node.args, self.argument_types): - validate_expected_type(arg, expected) - # TODO this should be moved to validate_call_args for kwarg in node.keywords: if kwarg.arg in self.call_site_kwargs: @@ -511,7 +508,6 @@ def fetch_call_return(self, node: vy_ast.Call) -> Optional[VyperType]: f"`{kwarg.arg}=` specified but {self.name}() does not return anything", kwarg.value, ) - validate_expected_type(kwarg.value, kwarg_settings.typ) if kwarg_settings.require_literal: if not isinstance(kwarg.value, vy_ast.Constant): raise InvalidType(