cddl-codegen icon indicating copy to clipboard operation
cddl-codegen copied to clipboard

Single element array members are treated as multiple

Open rooooooooob opened this issue 2 years ago • 1 comments

foo = [
   single: [uint]
]

is treated as:

foo = [
   single: [* uint]
]

As per the CDDL RFC:

If no occurrence indicator is specified, the group entry is to occur exactly once (as if 1*1 were specified)

You can work around this by doing:

single_uint = [uint]
foo = [
   single: single_uint
]

but it's not ideal. Ideally the fix would make this totally invisible to end-users and have Foo::single be of type uint directly with the array part just being a serialization detail.

rooooooooob avatar Dec 13 '22 21:12 rooooooooob

#210 addresses this for basic groups but the issue remains for other types e.g. [uint]. This is lower priority because the only time we've seen single element arrays like this in Cardano was for basic groups.

rooooooooob avatar Dec 26 '23 16:12 rooooooooob