Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Const sized byte array fail to generate #164

Open
karalabe opened this issue Jun 27, 2024 · 4 comments · May be fixed by #181
Open

Const sized byte array fail to generate #164

karalabe opened this issue Jun 27, 2024 · 4 comments · May be fixed by #181

Comments

@karalabe
Copy link
Contributor

karalabe commented Jun 27, 2024

This is fine:

type Address [20]byte

This blows up with byte array definition not understood by go/ast

const AddressLength = 20
type Address [AddressLength]byte
@ferranbt
Copy link
Owner

Do you have a repro of the issue? It does work for me here.

@iurii-ssv
Copy link

@ferranbt I'm encountering a different flavor of the issue @karalabe described above,

in your example you are defining the 3 - array size constant Issue164ElemSize, type Issue164Elem, struct Issue164 - all in the same package

if I try to use a constant from different (external) package - corresponds to Issue164ElemSize from your example - generator does produce _encoding.go file for me without errors, but the issue is it treats my array as slice (not constant size array!) - obviously failing to compile unless I adjust it manually.

Potentially somewhat related to #179

@ferranbt
Copy link
Owner

ferranbt commented Nov 4, 2024

Can you share a small repro of the issue?

@iurii-ssv
Copy link

iurii-ssv commented Nov 4, 2024

What's also curious is that latest version seems to be 0.1.3 while 0.1.4 seems to have been out for a while now as per https://github.com/ferranbt/fastssz/tags

➜ go install github.com/ferranbt/fastssz/sszgen@latest
...
➜ sszgen version
0.1.3

Simple example, github.com/attestantio/go-eth2-client/spec/bellatrix I'm using is just an arbitrary external package:

package storage

import "github.com/attestantio/go-eth2-client/spec/bellatrix"

//go:generate sszgen -path ./shares.go --objs storageShare

type storageShare struct {
	// Encoding generated will be for slice and not array
	FeeRecipientAddress [bellatrix.ExecutionAddressLength]byte
}

@ferranbt ferranbt linked a pull request Nov 6, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants