Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Jul 25, 2023
1 parent 39a9b93 commit d20e879
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions tests/parser/types/test_bytes.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -309,23 +309,23 @@ def assign():
def assign():
xs: bytes6 = b"abcdef"
""",
InvalidType,
InvalidLiteral,
),
(
"""
@external
def assign():
xs: bytes4 = 0xabcdef # bytes3 literal
""",
InvalidType,
InvalidLiteral,
),
(
"""
@external
def assign():
xs: bytes4 = 0x1234abcdef # bytes5 literal
""",
InvalidType,
InvalidLiteral,
),
]

Expand Down
2 changes: 1 addition & 1 deletion vyper/semantics/analysis/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion vyper/semantics/types/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()):
Expand Down

0 comments on commit d20e879

Please sign in to comment.