Skip to content

Commit

Permalink
fix raw log; add test
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Nov 20, 2024
1 parent c878485 commit 4ba0b10
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
16 changes: 16 additions & 0 deletions tests/functional/codegen/features/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,22 @@ def foo():
assert log.topics == [event_id, topic1, topic2, topic3]


valid_list = [
"""
topic: constant(bytes32) = 0x1212121212121210212801291212121212121210121212121212121212121212
@external
def foo():
raw_log([[topic]][0], b'')
"""
]


@pytest.mark.parametrize("code", valid_list)
def test_raw_log_pass(code):
assert compile_code(code) is not None


fail_list = [
(
"""
Expand Down
5 changes: 3 additions & 2 deletions vyper/builtins/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,8 @@ def fetch_call_return(self, node):
def infer_arg_types(self, node, expected_return_typ=None):
self._validate_arg_types(node)

if not isinstance(node.args[0], vy_ast.List) or len(node.args[0].elements) > 4:
arg = node.args[0].reduced()
if not isinstance(arg, vy_ast.List) or len(arg.elements) > 4:
raise InvalidType("Expecting a list of 0-4 topics as first argument", node.args[0])

# return a concrete type for `data`
Expand All @@ -1269,7 +1270,7 @@ def infer_arg_types(self, node, expected_return_typ=None):
def build_IR(self, expr, args, kwargs, context):
context.check_is_not_constant(f"use {self._id}", expr)

topics_length = len(expr.args[0].elements)
topics_length = len(expr.args[0].reduced().elements)
topics = args[0].args
topics = [unwrap_location(topic) for topic in topics]

Expand Down

0 comments on commit 4ba0b10

Please sign in to comment.