diff --git a/tests/parser/types/numbers/test_decimals.py b/tests/parser/types/numbers/test_decimals.py index 876d711154..1418eab063 100644 --- a/tests/parser/types/numbers/test_decimals.py +++ b/tests/parser/types/numbers/test_decimals.py @@ -3,7 +3,7 @@ import pytest -from vyper.exceptions import DecimalOverrideException, InvalidOperation +from vyper.exceptions import DecimalOverrideException, InvalidOperation, TypeMismatch from vyper.utils import DECIMAL_EPSILON, SizeLimits @@ -261,4 +261,4 @@ def foo() -> decimal: return 2.2 ** 2.0 """ - assert_compile_failed(lambda: get_contract(code), InvalidOperation) + assert_compile_failed(lambda: get_contract(code), TypeMismatch) diff --git a/vyper/builtins/functions.py b/vyper/builtins/functions.py index 0898712407..7e57555b08 100644 --- a/vyper/builtins/functions.py +++ b/vyper/builtins/functions.py @@ -1088,9 +1088,9 @@ def fetch_call_return(self, node): if revert_on_failure is not None: revert_on_failure = get_folded_value(revert_on_failure) - revert_on_failure = revert_on_failure if revert_on_failure is not None else True + revert_on_failure = revert_on_failure.value if revert_on_failure is not None else True - if outsize is None or outsize == 0: + if outsize is None or outsize.value == 0: if revert_on_failure: return None return BoolT() diff --git a/vyper/semantics/analysis/pre_typecheck.py b/vyper/semantics/analysis/pre_typecheck.py index 89ab20c5ff..98cfad06fb 100644 --- a/vyper/semantics/analysis/pre_typecheck.py +++ b/vyper/semantics/analysis/pre_typecheck.py @@ -68,7 +68,8 @@ def visit_FunctionDef(self, node): # visit type annotations of arguments # e.g. def foo(a: DynArray[uint256, 2 ** 8]): ... for arg in node.args.args: - self.visit(arg.annotation) + if arg.annotation: + self.visit(arg.annotation) for kwarg in node.args.defaults: self.visit(kwarg) @@ -94,7 +95,7 @@ def visit_StructDef(self, node): def visit_VariableDecl(self, node): self.visit(node.annotation) - if node.is_constant: + if node.is_constant and node.value: self.visit(node.value) # Stmts @@ -156,7 +157,7 @@ def visit_Attribute(self, node): self.visit(node.value) value_node = get_folded_value(node.value) if isinstance(value_node, vy_ast.Dict): - for k, v in zip(node.keys, node.values): + for k, v in zip(value_node.keys, value_node.values): if k.id == node.attr: node._metadata["folded_value"] = v return @@ -168,6 +169,10 @@ def visit_BinOp(self, node): left = get_folded_value(node.left) right = get_folded_value(node.right) if isinstance(left, type(right)) and isinstance(left, (vy_ast.Int, vy_ast.Decimal)): + if isinstance(node.op, (vy_ast.LShift, vy_ast.RShift)) and not ( + 0 <= right.value <= 256 + ): + return value = node.op._op(left.value, right.value) node._metadata["folded_value"] = type(left).from_node(node, value=value)