• Daniel Martí's avatar
    reflect: fix String of new array types · a4864094
    Daniel Martí authored
    When constructing a new type for an array type in ArrayOf, we don't
    reset tflag to 0. All the other methods in the package, such as SliceOf,
    do this already. This results in the new array type having weird issues
    when being printed, such as having tflagExtraStar set when it shouldn't.
    
    That flag removes the first char to get rid of '*', but when used
    incorrectly in this case it eats the '[' character leading to broken
    strings like "3]int".
    
    This was fixed in 56752eb2 for issue #16722, but ArrayOf was missed.
    
    Also make the XM test struct have a non-zero size as that leads to a
    division by zero panic in ArrayOf.
    
    Fixes #20311.
    
    Change-Id: I18f1027fdbe9f71767201e7424269c3ceeb23eb5
    Reviewed-on: https://go-review.googlesource.com/43130
    Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
    Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
    Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    a4864094
type.go 83.9 KB