]> Cypherpunks repositories - gostls13.git/commitdiff
disallow ordinary-type.(T), as in spec.
authorRuss Cox <rsc@golang.org>
Wed, 4 Mar 2009 22:50:25 +0000 (14:50 -0800)
committerRuss Cox <rsc@golang.org>
Wed, 4 Mar 2009 22:50:25 +0000 (14:50 -0800)
R=ken
OCL=25705
CL=25705

src/cmd/gc/walk.c
src/lib/reflect/type.go

index c7deefc91636f5039a2fd1dd4dbf114c54187933..3ae0f52f7c5a3da86f6dd3734ff469f83e6f70ef 100644 (file)
@@ -2851,6 +2851,9 @@ ifaceas1(Type *dst, Type *src, int explicit)
        if(src == T || dst == T)
                return Inone;
 
+       if(explicit && !isinter(src))
+               yyerror("cannot use .(T) on non-interface type %T", src);
+
        if(isinter(dst)) {
                if(isinter(src)) {
                        if(eqtype(dst, src, 0))
index 438f5b232362728d3e6cc244292d7a46d9fd7cba..96953f3b0f6f828d9abd1bf9d5a2afe07a29d225 100644 (file)
@@ -107,7 +107,8 @@ func newBasicType(name string, kind int, size int) Type {
 // Prebuilt basic types
 var (
        Missing = newBasicType(missingString, MissingKind, 1);
-       DotDotDot = newBasicType(dotDotDotString, DotDotDotKind, unsafe.Sizeof(true.(interface{})));
+       empty interface{};
+       DotDotDot = newBasicType(dotDotDotString, DotDotDotKind, unsafe.Sizeof(empty));
        Bool = newBasicType("bool", BoolKind, unsafe.Sizeof(true));
        Int = newBasicType("int", IntKind, unsafe.Sizeof(int(0)));
        Int8 = newBasicType("int8", Int8Kind, 1);