From: Rémy Oudompheng Date: Sat, 15 Dec 2012 18:37:59 +0000 (+0100) Subject: cmd/gc: fix defaultlit of shifts used in interface context. X-Git-Tag: go1.1rc2~1622 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1947960a6f87437cb3da4fd9341c0d265ff71cf6;p=gostls13.git cmd/gc: fix defaultlit of shifts used in interface context. Fixes #4545. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6937058 --- diff --git a/src/cmd/gc/const.c b/src/cmd/gc/const.c index 5720efc8e9..31ea3a251c 100644 --- a/src/cmd/gc/const.c +++ b/src/cmd/gc/const.c @@ -1052,6 +1052,11 @@ defaultlit(Node **np, Type *t) // When compiling x := 1<etype == TINTER) + t = T; if(t == T && (n->right->op == OLSH || n->right->op == ORSH)) { defaultlit(&n->left, T); defaultlit(&n->right, n->left->type); diff --git a/test/fixedbugs/issue4545.go b/test/fixedbugs/issue4545.go new file mode 100644 index 0000000000..3f2de16d20 --- /dev/null +++ b/test/fixedbugs/issue4545.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2012 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. + +// Issue 4545: untyped constants are incorrectly coerced +// to concrete types when used in interface{} context. + +package main + +import "fmt" + +func main() { + var s uint + fmt.Println(1.0 + 1<