Skip to content

InvalidLiteral when array literal contains elements of different lengths #4825

@cyberthirst

Description

@cyberthirst

Version Information

  • vyper Version (output of vyper --version): 17322bb

What's your issue about?

Mixing a concat() call with a string literal in a DynArray initializer fails to compile, even though both values are valid String[32] elements.

@external
def foo():
    x: DynArray[String[32], 10] = [concat("a", "a"), "bar"]
vyper.exceptions.InvalidLiteral: Array contains multiple, incompatible types

  contract "test.vy:2", function "foo", line 2:32
       1 def foo():
  ---> 2   x: DynArray[String[32], 10] = [concat("a", "a"), "bar"]
  ---------------------------------------^
       3

Using two plain literals works fine:

x: DynArray[String[32], 10] = ["aa", "bar"]  # compiles

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions