From 86c8efc99435bd14fafc4d62a19a83e9c9f362aa Mon Sep 17 00:00:00 2001 From: Ben Hauser Date: Sat, 10 Oct 2020 15:08:05 +0300 Subject: [PATCH] fix: add check to prevent dynamic-length struct as a function input --- vyper/context/types/function.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vyper/context/types/function.py b/vyper/context/types/function.py index 4fb80d8a6d..3e5dc5fc85 100644 --- a/vyper/context/types/function.py +++ b/vyper/context/types/function.py @@ -7,6 +7,7 @@ from vyper.context.namespace import get_namespace from vyper.context.types.bases import BaseTypeDefinition, DataLocation from vyper.context.types.indexable.sequence import TupleDefinition +from vyper.context.types.meta.struct import StructDefinition from vyper.context.types.utils import ( StringEnum, check_constant, @@ -290,6 +291,13 @@ def from_FunctionDef( type_definition = get_type_from_annotation( arg.annotation, location=DataLocation.CALLDATA, is_immutable=True ) + if isinstance(type_definition, StructDefinition) and type_definition.is_dynamic_size: + # this is a temporary restriction and should be removed once support for dynamically + # sized structs is implemented - https://github.com/vyperlang/vyper/issues/2190 + raise ArgumentException( + "Struct with dynamically sized data cannot be used as a function input", arg + ) + if value is not None: if not check_constant(value): raise StateAccessViolation(