...

Source file src/internal/types/testdata/fixedbugs/issue63563.go

Documentation: internal/types/testdata/fixedbugs

     1  // Copyright 2023 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package p
     6  
     7  var (
     8  	_ = int8(1 /* ERROR "constant 255 overflows int8" */ <<8 - 1)
     9  	_ = int16(1 /* ERROR "constant 65535 overflows int16" */ <<16 - 1)
    10  	_ = int32(1 /* ERROR "constant 4294967295 overflows int32" */ <<32 - 1)
    11  	_ = int64(1 /* ERROR "constant 18446744073709551615 overflows int64" */ <<64 - 1)
    12  
    13  	_ = uint8(1 /* ERROR "constant 256 overflows uint8" */ << 8)
    14  	_ = uint16(1 /* ERROR "constant 65536 overflows uint16" */ << 16)
    15  	_ = uint32(1 /* ERROR "constant 4294967296 overflows uint32" */ << 32)
    16  	_ = uint64(1 /* ERROR "constant 18446744073709551616 overflows uint64" */ << 64)
    17  )
    18  
    19  func _[P int8 | uint8]() {
    20  	_ = P(0)
    21  	_ = P(1 /* ERROR "constant 255 overflows int8 (in P)" */ <<8 - 1)
    22  }
    23  
    24  func _[P int16 | uint16]() {
    25  	_ = P(0)
    26  	_ = P(1 /* ERROR "constant 65535 overflows int16 (in P)" */ <<16 - 1)
    27  }
    28  
    29  func _[P int32 | uint32]() {
    30  	_ = P(0)
    31  	_ = P(1 /* ERROR "constant 4294967295 overflows int32 (in P)" */ <<32 - 1)
    32  }
    33  
    34  func _[P int64 | uint64]() {
    35  	_ = P(0)
    36  	_ = P(1 /* ERROR "constant 18446744073709551615 overflows int64 (in P)" */ <<64 - 1)
    37  }
    38  

View as plain text