From 0933c9f8d5685c696684a02aca413faa2dc0ce57 Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Sat, 30 Sep 2023 10:43:57 +0800 Subject: [PATCH] set max len if not annotated --- vyper/builtins/functions.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vyper/builtins/functions.py b/vyper/builtins/functions.py index 7a128567a0..d71592ee1f 100644 --- a/vyper/builtins/functions.py +++ b/vyper/builtins/functions.py @@ -377,7 +377,11 @@ def build_IR(self, expr, args, kwargs, context): # Get returntype string or bytes dst_typ = expr._metadata.get("type") - assert isinstance(dst_typ, _BytestringT) or is_bytes32 + assert isinstance(dst_typ, _BytestringT) + + # set the length of the return type if it was not defined in annotation + if dst_typ.length == 0: + dst_typ.set_length(dst_maxlen) # allocate a buffer for the return value buf = context.new_internal_variable(BytesT(buflen))