summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2009-03-10 16:39:23 -0700
committerRobert Griesemer <gri@golang.org>2009-03-10 16:39:23 -0700
commitc67af3402de9a22624906b23d878a1b6b72a475c (patch)
treefd4093634abf183cc747e67f7171076a56c6ba2f
parent4c9156602fe8db7d6c088f6d38fad0cd78138607 (diff)
downloadgolang-c67af3402de9a22624906b23d878a1b6b72a475c.tar.gz
constant conversion of int (non-ideal) constant doesn't work
R=rsc DELTA=20 (20 added, 0 deleted, 0 changed) OCL=26054 CL=26062
-rw-r--r--test/bugs/bug138.go19
-rw-r--r--test/golden.out5
2 files changed, 24 insertions, 0 deletions
diff --git a/test/bugs/bug138.go b/test/bugs/bug138.go
new file mode 100644
index 000000000..09c61e05c
--- /dev/null
+++ b/test/bugs/bug138.go
@@ -0,0 +1,19 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// $G $D/$F.go || echo BUG should compile
+
+package main
+
+func main() {
+ const c int = -1;
+ var i int = -1;
+ var xc uint = uint(c); // this does not work
+ var xi uint = uint(i); // this works
+}
+
+/*
+bug138.go:8: overflow converting constant to uint
+bug138.go:8: illegal combination of literals CONV 7
+*/
diff --git a/test/golden.out b/test/golden.out
index bb1e2cb44..31616f4fa 100644
--- a/test/golden.out
+++ b/test/golden.out
@@ -154,6 +154,11 @@ bugs/bug137.go:9: break label is not defined: L2
bugs/bug137.go:15: break label is not defined: L4
BUG should compile
+=========== bugs/bug138.go
+bugs/bug138.go:8: overflow converting constant to uint
+bugs/bug138.go:8: illegal combination of literals CONV 7
+BUG should compile
+
=========== fixedbugs/bug016.go
fixedbugs/bug016.go:7: overflow converting constant to uint