github.com/4ad/go@v0.0.0-20161219182952-69a12818b605/test/fixedbugs/issue9036.go (about)

     1  // errorcheck
     2  
     3  // Copyright 2015 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  // Expects to see error messages on 'p' exponents.
     8  
     9  package main
    10  
    11  import "fmt"
    12  
    13  const (
    14  	x1 = 1.1    // float
    15  	x2 = 1e10   // float
    16  	x3 = 0x1e10 // integer (e is a hex digit)
    17  )
    18  
    19  // 'p' exponents are invalid - the 'p' is not considered
    20  // part of a floating-point number, but introduces a new
    21  // (unexpected) name.
    22  //
    23  // Error recovery is not ideal and we use a new declaration
    24  // each time for the parser to recover.
    25  
    26  const x4 = 0x1p10 // ERROR "unexpected p10"
    27  const x5 = 1p10   // ERROR "unexpected p10"
    28  const x6 = 0p0    // ERROR "unexpected p0"
    29  
    30  func main() {
    31  	fmt.Printf("%g %T\n", x1, x1)
    32  	fmt.Printf("%g %T\n", x2, x2)
    33  	fmt.Printf("%g %T\n", x3, x3)
    34  	fmt.Printf("%g %T\n", x4, x4)
    35  	fmt.Printf("%g %T\n", x5, x5)
    36  	fmt.Printf("%g %T\n", x6, x6)
    37  }