• Daniel Martí's avatar
    cmd/vet: warn on unkeyed struct pointer literals · 6ded116a
    Daniel Martí authored
    We did warn on them in some cases, but not others. In particular, if one
    used a slice composite literal with struct pointer elements, and omitted
    the type of an element's composite literal, it would not get any warning
    even if it should get one.
    
    The issue is that typ.Underlying() can be of type *types.Pointer. Skip
    those levels of indirection before checking for a *types.Struct
    underlying type.
    
    isLocalType also needed a bit of tweaking to ignore dereferences.
    Perhaps that can be rewritten now that we have type info, but let's
    leave it for another time.
    
    Fixes #23539.
    
    Change-Id: I727a497284df1325b70d47a756519f5db1add25d
    Reviewed-on: https://go-review.googlesource.com/89715
    Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    6ded116a
composite.go 2.17 KB