1 // errchk $G -e $D/$F.go
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.
9 // explicit conversion of constants is work in progress.
10 // the ERRORs in this block are debatable, but they're what
11 // the language spec says for now.
13 var x2 string = string(1);
14 var x3 = int(1.5); // ERROR "convert|truncate"
15 var x4 int = int(1.5); // ERROR "convert|truncate"
16 var x5 = "a" + string(1);
17 var x6 = int(1e100); // ERROR "overflow"
18 var x7 = float(1e1000); // ERROR "overflow"
20 // implicit conversions merit scrutiny
22 var bad1 string = 1; // ERROR "conver|incompatible"
23 var bad2 = s + 1; // ERROR "conver|incompatible"
24 var bad3 = s + 'a'; // ERROR "conver|incompatible"
25 var bad4 = "a" + 1; // ERROR "literals|incompatible|convert"
26 var bad5 = "a" + 'a'; // ERROR "literals|incompatible|convert"
28 var bad6 int = 1.5; // ERROR "convert|truncate"
29 var bad7 int = 1e100; // ERROR "overflow"
30 var bad8 float32 = 1e200; // ERROR "overflow"
32 // but these implicit conversions are okay
33 var good1 string = "a";
36 var good4 float = 1e20;