diff --git a/test/bugs/bug113.go b/test/bugs/bug113.go new file mode 100644 index 00000000000..e794868a4ae --- /dev/null +++ b/test/bugs/bug113.go @@ -0,0 +1,20 @@ +// $G $D/$F.go && $L $F.$A && (! ./$A.out || echo BUG: should not succeed) + +// 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. + +package main +type I interface { }; +func foo1(i int) int { return i } +func foo2(i int32) int32 { return i } +func main() { + var i I; + i = 1; + var v1 int = i; + if foo1(v1) != 1 { panicln(1) } + var v2 int32 = i.(int).(int32); + if foo1(v2) != 1 { panicln(2) } + var v3 int32 = i; // This implicit type conversion should fail at runtime. + if foo1(v3) != 1 { panicln(3) } +} diff --git a/test/golden.out b/test/golden.out index ec8b29af1d8..6a138952caa 100644 --- a/test/golden.out +++ b/test/golden.out @@ -156,6 +156,9 @@ bugs/bug109.go:6: illegal types for operand: RETURN float64 BUG: should compile +=========== bugs/bug113.go +BUG: should not succeed + =========== fixedbugs/bug016.go fixedbugs/bug016.go:7: overflow converting constant to uint32 diff --git a/test/ken/interbasic.go b/test/ken/interbasic.go index 2603d2560e8..e4b0b79a436 100644 --- a/test/ken/interbasic.go +++ b/test/ken/interbasic.go @@ -86,7 +86,8 @@ main() u64 = 765432; ia[12] = u64; s = ia[0]; if s != "xxx" { panicln(0,s); } - i32 = ia[1]; if i32 != 12345 { panicln(1,i32); } + i32 = ia[1].(int).(int32); + if i32 != 12345 { panicln(1,i32); } b = ia[2]; if b != true { panicln(2,b); } s = ia[3]; if s != "now is" { panicln(3,s); }