• Daniel Martí's avatar
    cmd/compile: fix crash on invalid struct literal · ba6974fd
    Daniel Martí authored
    If one tries to use promoted fields in a struct literal, the compiler
    errors correctly. However, if the embedded fields are of struct pointer
    type, the field.Type.Sym.Name expression below panics.
    
    This is because field.Type.Sym is nil in that case. We can simply use
    field.Sym.Name in this piece of code though, as it only concerns
    embedded fields, in which case what we are after is the field name.
    
    Added a test mirroring fixedbugs/issue23609.go, but with pointer types.
    
    Fixes #26416.
    
    Change-Id: Ia46ce62995c9e1653f315accb99d592aff2f285e
    Reviewed-on: https://go-review.googlesource.com/124395
    Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: default avatarEmmanuel Odeke <emm.odeke@gmail.com>
    Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
    ba6974fd
issue26416.go 597 Bytes