From d20e8799ea5bf7bd04c259c5cc4361c53b0506a6 Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Tue, 25 Jul 2023 14:33:31 +0800 Subject: [PATCH] wip --- tests/parser/types/test_bytes.py | 8 ++++---- vyper/semantics/analysis/local.py | 2 +- vyper/semantics/types/primitives.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/parser/types/test_bytes.py b/tests/parser/types/test_bytes.py index 01ec75d5c1..240c4225bf 100644 --- a/tests/parser/types/test_bytes.py +++ b/tests/parser/types/test_bytes.py @@ -1,6 +1,6 @@ import pytest -from vyper.exceptions import InvalidType, TypeMismatch +from vyper.exceptions import InvalidLiteral, InvalidType, TypeMismatch def test_test_bytes(get_contract_with_gas_estimation, assert_tx_failed): @@ -309,7 +309,7 @@ def assign(): def assign(): xs: bytes6 = b"abcdef" """, - InvalidType, + InvalidLiteral, ), ( """ @@ -317,7 +317,7 @@ def assign(): def assign(): xs: bytes4 = 0xabcdef # bytes3 literal """, - InvalidType, + InvalidLiteral, ), ( """ @@ -325,7 +325,7 @@ def assign(): def assign(): xs: bytes4 = 0x1234abcdef # bytes5 literal """, - InvalidType, + InvalidLiteral, ), ] diff --git a/vyper/semantics/analysis/local.py b/vyper/semantics/analysis/local.py index 3184fea0b4..6e8c81fad0 100644 --- a/vyper/semantics/analysis/local.py +++ b/vyper/semantics/analysis/local.py @@ -274,7 +274,7 @@ def visit_Assign(self, node): target.validate_modification(node, self.func.mutability) self.expr_visitor.visit(node.target, target.typ) - self.expr_visitor.visit(node.value) + self.expr_visitor.visit(node.value, target.typ) value_typ = node.value._metadata.get("type") if not target.typ.compare_type(value_typ): diff --git a/vyper/semantics/types/primitives.py b/vyper/semantics/types/primitives.py index 07d1a21a94..870791fa30 100644 --- a/vyper/semantics/types/primitives.py +++ b/vyper/semantics/types/primitives.py @@ -86,7 +86,7 @@ def validate_literal(self, node: vy_ast.Constant) -> None: val = node.value if node.n_bytes != self.m: - raise InvalidLiteral("Invalid literal for type {self}", node) + raise InvalidLiteral(f"Invalid literal for type {self}", node) nibbles = val[2:] # strip leading 0x if nibbles not in (nibbles.lower(), nibbles.upper()):