Open sanjit-bhat opened 8 months ago
This is because at least when we initially developed Goose the go/types package didn't help differentiate nil for a slice vs a pointer (it assigned them the same "untyped nil" type as far as I recall). It's possible to get type info from context, but the whole point of using go/types was to not do this kind of type inference work.
At least from following the release notes I don't believe this has changed, but it would be nice to encode this as a test case and check that it still holds.
For your particular example I believe letting s
be initialized to its default value will use the type from the struct declaration, which will work correctly.
gets translated into
One bad thing that happens as a result is that the new struct fails
val_ty
becauseslice.nil
is not a validptrT
.