Skip to content

Commit

Permalink
fix: add check to prevent dynamic-length struct as a function input
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Oct 10, 2020
1 parent 67f8890 commit 86c8efc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions vyper/context/types/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 86c8efc

Please sign in to comment.