Skip to content

Commit

Permalink
gc: bug327
Browse files Browse the repository at this point in the history
Fixes golang#1674.

R=ken2
CC=golang-dev
https://golang.org/cl/4368057
  • Loading branch information
rsc committed Apr 7, 2011
1 parent 62c2481 commit 35c880b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/cmd/gc/subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1889,8 +1889,9 @@ assignop(Type *src, Type *dst, char **why)
return OCONVNOP;

// 2. src and dst have identical underlying types
// and either src or dst is not a named type.
if(eqtype(src->orig, dst->orig) && (src->sym == S || dst->sym == S))
// and either src or dst is not a named type or
// both are interface types.
if(eqtype(src->orig, dst->orig) && (src->sym == S || dst->sym == S || src->etype == TINTER))
return OCONVNOP;

// 3. dst is an interface type and src implements dst.
Expand Down
18 changes: 18 additions & 0 deletions test/fixedbugs/bug327.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// $G $D/$F.go && $L $F.$A && ./$A.out

// Copyright 2011 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 (
a interface{}
b interface{}
)

func main() {
x := a(1)
z := b(x)
_ = z
}

0 comments on commit 35c880b

Please sign in to comment.