blob: dd5c88958d762250b78286e0267f78734a993d14 [file] [log] [blame]
Russ Cox8f194bf2009-03-12 19:04:38 -07001// $G $D/$F.go && $L $F.$A && ./$A.out
2
3// Copyright 2009 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
7package main
8
9import "fmt"
10
11type T int
Rob Pike325cf8e2010-03-24 16:46:53 -070012
Rob Piked482c162010-06-14 17:16:35 -070013func (t T) String() string { return fmt.Sprintf("T%d", int(t)) }
Russ Cox8f194bf2009-03-12 19:04:38 -070014
15const (
Rob Pike325cf8e2010-03-24 16:46:53 -070016 A T = 1 << (1 << iota)
17 B
18 C
19 D
20 E
Russ Cox8f194bf2009-03-12 19:04:38 -070021)
22
23func main() {
Rob Pike325cf8e2010-03-24 16:46:53 -070024 s := fmt.Sprintf("%v %v %v %v %v", A, B, C, D, E)
Russ Cox8f194bf2009-03-12 19:04:38 -070025 if s != "T2 T4 T16 T256 T65536" {
Rob Pike325cf8e2010-03-24 16:46:53 -070026 println("type info didn't propagate in const: got", s)
27 panic("fail")
Russ Cox8f194bf2009-03-12 19:04:38 -070028 }
29}