ethereum / wiki

The Ethereum Wiki
https://www.ethereum.org
14.75k stars 2.56k forks source link

ABI spec question: fixed-size zero-length arrays (`<type>[0]`) #614

Closed Qqwy closed 4 years ago

Qqwy commented 6 years ago

In the ABI spec section Types, the following statement is written:

[M]: a fixed-length array of M elements, M >= 0, of the given type.

In the section Formal specification of encoding, the following statement is written:

T[k] for any dynamic T and any k >= 0

Does that mean that we can have an array (of either static or dynamic elements) with fixed size, where this fixed size is 0? (so the type int256[0], or bool[0], or string[0], or bytes[][][][][0][]?) I can understand the need for supporting a zero-tuple (it is very common from functional languages), but I do not understand what a fixed-size zero-length array is supposed to be for.

Do they exist, or is this an off-by-one error in the documentation? If they do exist, are these encoded as 'empty arguments' that do not take up any space in the hexadecimal ABI string?

jamesray1 commented 5 years ago

Please see https://github.com/ethereum/wiki/blob/master/ISSUE_TEMPLATE.md.