• 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: 's avatarEmmanuel Odeke <emm.odeke@gmail.com>
    Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
    ba6974fd
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...