-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Call Unalias()
in IsNilable()
to support gotypesalias=1
#3304
Conversation
Co-authored-by: Gilad Maymon <gilad.maymon@wiz.io>
891a170
to
1aeff60
Compare
codegen/config/binder.go
Outdated
@@ -520,6 +520,7 @@ func (b *Binder) CopyModifiersFromAst(t *ast.Type, base types.Type) types.Type { | |||
} | |||
|
|||
func IsNilable(t types.Type) bool { | |||
t = code.Unalias(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should call types.Unalias(t)
so we'll Unalias even in Go 1.22?
Currently in Go 1.22 calling this with a nilable alias type returns false.
@StevenACoffman, @a8m WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really need to continue to support Go 1.22, and I don't think we can just assume people have gotypesalias=1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'll call types.Unalias()
here, that way we'll make sure IsNilable()
is reliable no matter what.
Also - we don't need the pointer base type unaliasing from code.Unalias()
here.
Thanks! I really appreciate your fix here! Looking forward to your next contribution! |
Thanks @StevenACoffman! |
Right now! Just released! |
Fixed false
IsNilable()
value for any (or any other aliased type) whengotypesalias=1
(default since Go 1.23.0)Fixes #3301
I have: