• Daniel Martí's avatar
    cmd/compile: make bad Ctypes be only 0 · f14f7b31
    Daniel Martí authored
    Before, -1 meant a node being nil or not an OLITERAL, and 0 meant an
    OLITERAL missing a Val.
    
    However, the use of this value was confusing and led to some issues,
    such as swt.go checking for < 0 instead of <= 0, causing panics.
    
    We never need to differentiate these two cases, so collapse both into 0.
    To make it clear that negative values can no longer happen, make Ctype
    an uint8.
    
    With this change, we can now get rid of the two n.Type == nil checks
    in swt.go added to fix a couple of these panics.
    
    Thanks to Matthew Dempsky for spotting this inconsistency.
    
    Fixes #22001.
    
    Change-Id: I51c65a76f38a3e16788b6a3b57932dad3436dc7e
    Reviewed-on: https://go-review.googlesource.com/69510
    Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
    Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    f14f7b31
const.go 32.7 KB