Closed Wessie closed 6 months ago
Can you provide a short example to reproduce this?
a := arbitrary.DefaultArbitraries()
gen := a.GenForType(reflect.TypeOf([20]byte{}))
fmt.Println(gen)
will print <nil>
https://go.dev/play/p/1_Mxhuc5GKl
Can you check if the current master branch fixes your problem?
Yes, this fixes array support, but it would still be a nice quality of life change if passing an unsupported type to GenForType
actually panicked with a reasonable message indicating such.
Also there is a typo in the array_shink.go
filename
I'm sorry, it seems panicking on unsupported types is a breaking change.
Since struct types ignore unsupported fields it means anyone generating structs with unsupported fields now gets a panic instead.
It's fine for the map/slice/array versions but structs explicitly ignore fields https://github.com/leanovate/gopter/blob/master/arbitrary/gen_for_kind.go#L331 if GenForType returns nil.
Sorry for the shortsightedness, maybe we can move the check into Arbitraries.ForAll
instead.
Removed the panic for now, have to dig a bit deeper into the ForAll
passing an array type to
GenForType
returns nil, and this only panics once the properties are actually ran so it isn't obvious what the issue is, it produces the following stack trace:GenForType
should probably panic if there is an unsupported type