From ad500041ea3b0e6c9dbb63035f8aa2d219520713 Mon Sep 17 00:00:00 2001 From: R?my Oudompheng Date: Tue, 2 Jul 2013 09:08:43 +0200 Subject: cmd/gc: fix computation of equality class of types. A struct with a single field was considered as equivalent to the field type, which is incorrect is the field is blank. Fields with padding could make the compiler think some types are comparable when they are not. Fixes issue 5698. R=rsc, golang-dev, daniel.morsing, bradfitz, gri, r CC=golang-dev https://codereview.appspot.com/10271046 --- test/blank1.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/blank1.go') diff --git a/test/blank1.go b/test/blank1.go index 4edb2db70..f46a50051 100644 --- a/test/blank1.go +++ b/test/blank1.go @@ -13,9 +13,16 @@ var t struct { _ int } +type T struct { + _ []int +} + func main() { _() // ERROR "cannot use _ as value" x := _+1 // ERROR "cannot use _ as value" _ = x _ = t._ // ERROR "cannot refer to blank field" + + var v1, v2 T + _ = v1 == v2 // ERROR "cannot be compared|non-comparable" } -- cgit v1.2.1