Closed cvkem closed 4 years ago
Thank you for an amazing bug report. It really lifted my spirits.
This should be a case study of how it should be done. I was showing this off to friends last night at dinner. I will now strive to provide this quality of bug reports myself.
Here is a fix https://github.com/awalterschulze/goderive/commit/9a5b9356be09536f53d589d4e13412301c87df89
Hi Walter,
I think you have a very interesting library and goderive should get more attention as it provides a type-safe and performant solution for many operations. The goderive path is much cleaner than libraries based on the generic interface{} type.
However, when doing my first work I ran into a situation where the goderive generator failed and ended up in an infinite recursion. I have reproduced the issue on you example file of unique.go. By changing the type from a slice of pointers to a slice of objects the code runs into an infinite recursion.
unique.go.txt
I was not able to capture the full stacktrace as it is too long. However, by squeezing the maximal stackize in goderive I could get a full stacktrace which is shown in the file below.
stackTrace.txt
As you look at the bottom of the file you see that starting from generate.go line 246 it move to equal.go line 169 and after some steps it starts to jump between equal.go line 460 and line 475 (in my stacktrace the numbers are a bit higher as I did build in some fmt.Printf statements for debugging.
I hope you are able to see what is going on here. I´m a bit puzzled here as the code of unique is not even called in this stacktrace, but I guess there is a logical explanation for that too :-)
Cees.