ferranbt / fastssz

Fast Ethereum2.0 SSZ encoder/decoder
MIT License
74 stars 44 forks source link

Two structs by the same name, in different packages, causes an error #49

Closed prestonvanloon closed 3 years ago

prestonvanloon commented 3 years ago

Example

// a/stuff.go
package "a"

type Thing struct {}

type FooBar struct {}
// b/stuff.go
package "b"

import "a"

type Thing struct {
  Item *a.FooBar
}

type Sandwhich struct {
  Size uint64

  Item *a.FooBar
}

Running sszgen on b.Sandwhich causes conflicts between unrelated items in package a and package b.

[ERR]: two structs share the same name Thing
rauljordan commented 3 years ago

Same as #46

prestonvanloon commented 3 years ago

Same as #46

I think this is a bit different than #46. This issue manifests on top of the PR for #46.

The root of the issue boils down to the various mappings of structs by their name only. If there are multiple packages to consider, there may be multiple structs by the same name. Unfortunately, this seems to happen whether or not you wanted to generate ssz methods for the struct or it simple exists in the same package as structs you did want to generate ssz methods.

I started looking at changing the name in the map to the full package name + struct name. Looking for some guidance before committing substantial time on sszgen.

This is a big blocker downstream at prysmaticlabs/prysm.