]> Cypherpunks repositories - gostls13.git/commitdiff
insert type assertions when narrowing.
authorRuss Cox <rsc@golang.org>
Thu, 12 Feb 2009 01:55:16 +0000 (17:55 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 12 Feb 2009 01:55:16 +0000 (17:55 -0800)
R=r
OCL=24349
CL=24913

17 files changed:
src/lib/json/generic.go
src/lib/json/struct.go
src/lib/reflect/all_test.go
src/lib/reflect/tostring.go
src/lib/reflect/type.go
src/lib/reflect/value.go
test/chan/powser2.go
test/fixedbugs/bug027.go
test/fixedbugs/bug054.go
test/fixedbugs/bug089.go
test/fixedbugs/bug113.go
test/interface2.go
test/interface5.go
test/ken/embed.go
test/ken/interbasic.go
test/ken/interfun.go
usr/gri/pretty/parser.go

index b57fcb12e22ece36a94c115352d33ca1fb04d045..08ae8dc29fbdcdc90a99de08cf3b63c57d04a16c 100644 (file)
@@ -75,7 +75,7 @@ func (j *_Array) Elem(i int) Json {
        if i < 0 || i >= j.a.Len() {
                return Null
        }
-       return j.a.At(i)
+       return j.a.At(i).(Json)
 }
 func (j *_Array) String() string {
        s := "[";
@@ -232,7 +232,7 @@ func (b *_JsonBuilder) Get() Json {
        case b.ptr != nil:
                return *b.ptr;
        case b.a != nil:
-               return b.a.At(b.i);
+               return b.a.At(b.i).(Json);
        case b.m != nil:
                return b.m[b.k];
        }
index f37ee461efa9f6ad372173cd71ff3a7549a0ddf8..82e0a80a7bd38807e0cb97ae60ba04154ed7be8b 100644 (file)
@@ -122,7 +122,7 @@ func (b *_StructBuilder) Array() {
                pv := v.(reflect.PtrValue);
                psubtype := pv.Type().(reflect.PtrType).Sub();
                if pv.Get() == nil && psubtype.Kind() == reflect.ArrayKind {
-                       av := reflect.NewSliceValue(psubtype, 0, 8);
+                       av := reflect.NewSliceValue(psubtype.(reflect.ArrayType), 0, 8);
                        pv.SetSub(av);
                }
        }
@@ -148,7 +148,7 @@ func (b *_StructBuilder) Elem(i int) Builder {
                                for n <= i {
                                        n *= 2
                                }
-                               av1 := reflect.NewSliceValue(av.Type(), av.Len(), n);
+                               av1 := reflect.NewSliceValue(av.Type().(reflect.ArrayType), av.Len(), n);
                                av1.CopyFrom(av, av.Len());
                                pv.SetSub(av1);
                                av = av1;
index a840fc89287e820312bd77c4e5838545c9b93a68..f6428fdf3843613e7b809692caded5f2cfd2dee3 100644 (file)
@@ -270,7 +270,7 @@ func TestAll(tt *testing.T) {       // TODO(r): wrap up better
        assert(typ.String(), "[]uint32");
 
        t = reflect.ParseTypeString("", "[]int32");
-       v := reflect.NewSliceValue(t, 5, 10);
+       v := reflect.NewSliceValue(t.(ArrayType), 5, 10);
        t1 := reflect.ParseTypeString("", "*[]int32");
        v1 := reflect.NewInitValue(t1);
        if v1 == nil { panic("V1 is nil"); }
@@ -308,7 +308,7 @@ func TestCopyArray(t *testing.T) {
                }
        }
        for tocopy := 1; tocopy <= 7; tocopy++ {
-               vb.(PtrValue).Sub().(ArrayValue).CopyFrom(va.(PtrValue).Sub(), tocopy);
+               vb.(PtrValue).Sub().(ArrayValue).CopyFrom(va.(PtrValue).Sub().(ArrayValue), tocopy);
                for i := 0; i < tocopy; i++ {
                        if a[i] != b[i] {
                                t.Errorf("1 tocopy=%d a[%d]=%d, b[%d]=%d",
index d317e1a68f5dcc9576d839ce6b6dea4d0d250532..b2ccfdf483288d241ff43db487f33457e5b64ed2 100644 (file)
@@ -105,9 +105,9 @@ func TypeToString(typ Type, expand bool) string {
                }
                return str + TypeToString(c.Elem(), false);
        case StructKind:
-               return "struct{" + typeFieldsToString(typ, ";") + "}";
+               return "struct{" + typeFieldsToString(typ.(StructType), ";") + "}";
        case InterfaceKind:
-               return "interface{" + typeFieldsToString(typ, ";") + "}";
+               return "interface{" + typeFieldsToString(typ.(InterfaceType), ";") + "}";
        case FuncKind:
                f := typ.(FuncType);
                str = "(" + typeFieldsToString(f.In(), ",") + ")";
index b02ad32d7aaed345c765e34d9794f2b357de20d2..d949f23f40006e237c665c80b25f96da798a4df2 100644 (file)
@@ -149,6 +149,12 @@ func (t *stubType) Get() Type {
 // -- Pointer
 
 type PtrType interface {
+       // TODO: Type;
+       Kind()  int;
+       Name()  string;
+       String()        string;
+       Size()  int;
+
        Sub()   Type
 }
 
@@ -168,6 +174,12 @@ func (t *ptrTypeStruct) Sub() Type {
 // -- Array
 
 type ArrayType interface {
+       // TODO: Type;
+       Kind()  int;
+       Name()  string;
+       String()        string;
+       Size()  int;
+
        IsSlice()       bool;
        Len()   int;
        Elem()  Type;
@@ -207,6 +219,12 @@ func (t *arrayTypeStruct) Elem() Type {
 // -- Map
 
 type MapType interface {
+       // TODO: Type;
+       Kind()  int;
+       Name()  string;
+       String()        string;
+       Size()  int;
+
        Key()   Type;
        Elem()  Type;
 }
@@ -232,6 +250,12 @@ func (t *mapTypeStruct) Elem() Type {
 // -- Chan
 
 type ChanType interface {
+       // TODO: Type;
+       Kind()  int;
+       Name()  string;
+       String()        string;
+       Size()  int;
+
        Dir()   int;
        Elem()  Type;
 }
@@ -263,6 +287,12 @@ func (t *chanTypeStruct) Elem() Type {
 // -- Struct
 
 type StructType interface {
+       // TODO: Type;
+       Kind()  int;
+       Name()  string;
+       String()        string;
+       Size()  int;
+
        Field(int)      (name string, typ Type, tag string, offset int);
        Len()   int;
 }
@@ -323,6 +353,12 @@ func (t *structTypeStruct) Len() int {
 // -- Interface
 
 type InterfaceType interface {
+       // TODO: Type;
+       Kind()  int;
+       Name()  string;
+       String()        string;
+       Size()  int;
+
        Field(int)      (name string, typ Type, tag string, offset int);
        Len()   int;
 }
@@ -349,6 +385,12 @@ var nilInterface = newInterfaceTypeStruct("nil", "", make([]structField, 0));
 // -- Func
 
 type FuncType interface {
+       // TODO: Type;
+       Kind()  int;
+       Name()  string;
+       String()        string;
+       Size()  int;
+
        In()    StructType;
        Out()   StructType;
 }
index 8a2706e9745d33761044e7945e3f6588f0dc820e..6464d7e6d2db74de6362b82c2ad753ddda1d6484 100644 (file)
@@ -66,9 +66,11 @@ type creatorFn func(typ Type, addr Addr) Value
 // -- Missing
 
 type MissingValue interface {
+       // TODO: Value;
        Kind()  int;
        Type()  Type;
        Addr()  Addr;
+       Interface()     interface {};
 }
 
 type missingValueStruct struct {
@@ -82,10 +84,14 @@ func missingCreator(typ Type, addr Addr) Value {
 // -- Int
 
 type IntValue interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   int;
        Set(int);
-       Type()  Type;
 }
 
 type intValueStruct struct {
@@ -107,10 +113,14 @@ func (v *intValueStruct) Set(i int) {
 // -- Int8
 
 type Int8Value interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   int8;
        Set(int8);
-       Type()  Type;
 }
 
 type int8ValueStruct struct {
@@ -132,10 +142,14 @@ func (v *int8ValueStruct) Set(i int8) {
 // -- Int16
 
 type Int16Value interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   int16;
        Set(int16);
-       Type()  Type;
 }
 
 type int16ValueStruct struct {
@@ -157,10 +171,14 @@ func (v *int16ValueStruct) Set(i int16) {
 // -- Int32
 
 type Int32Value interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   int32;
        Set(int32);
-       Type()  Type;
 }
 
 type int32ValueStruct struct {
@@ -182,10 +200,14 @@ func (v *int32ValueStruct) Set(i int32) {
 // -- Int64
 
 type Int64Value interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   int64;
        Set(int64);
-       Type()  Type;
 }
 
 type int64ValueStruct struct {
@@ -207,10 +229,14 @@ func (v *int64ValueStruct) Set(i int64) {
 // -- Uint
 
 type UintValue interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   uint;
        Set(uint);
-       Type()  Type;
 }
 
 type uintValueStruct struct {
@@ -232,10 +258,14 @@ func (v *uintValueStruct) Set(i uint) {
 // -- Uint8
 
 type Uint8Value interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   uint8;
        Set(uint8);
-       Type()  Type;
 }
 
 type uint8ValueStruct struct {
@@ -257,10 +287,14 @@ func (v *uint8ValueStruct) Set(i uint8) {
 // -- Uint16
 
 type Uint16Value interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   uint16;
        Set(uint16);
-       Type()  Type;
 }
 
 type uint16ValueStruct struct {
@@ -282,10 +316,14 @@ func (v *uint16ValueStruct) Set(i uint16) {
 // -- Uint32
 
 type Uint32Value interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   uint32;
        Set(uint32);
-       Type()  Type;
 }
 
 type uint32ValueStruct struct {
@@ -307,10 +345,14 @@ func (v *uint32ValueStruct) Set(i uint32) {
 // -- Uint64
 
 type Uint64Value interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   uint64;
        Set(uint64);
-       Type()  Type;
 }
 
 type uint64ValueStruct struct {
@@ -332,10 +374,14 @@ func (v *uint64ValueStruct) Set(i uint64) {
 // -- Uintptr
 
 type UintptrValue interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   uintptr;
        Set(uintptr);
-       Type()  Type;
 }
 
 type uintptrValueStruct struct {
@@ -357,10 +403,14 @@ func (v *uintptrValueStruct) Set(i uintptr) {
 // -- Float
 
 type FloatValue interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   float;
        Set(float);
-       Type()  Type;
 }
 
 type floatValueStruct struct {
@@ -382,10 +432,14 @@ func (v *floatValueStruct) Set(f float) {
 // -- Float32
 
 type Float32Value interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   float32;
        Set(float32);
-       Type()  Type;
 }
 
 type float32ValueStruct struct {
@@ -407,10 +461,14 @@ func (v *float32ValueStruct) Set(f float32) {
 // -- Float64
 
 type Float64Value interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   float64;
        Set(float64);
-       Type()  Type;
 }
 
 type float64ValueStruct struct {
@@ -432,10 +490,14 @@ func (v *float64ValueStruct) Set(f float64) {
 // -- Float80
 
 type Float80Value interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   float80;
        Set(float80);
-       Type()  Type;
 }
 
 type float80ValueStruct struct {
@@ -460,10 +522,14 @@ func (v *Float80ValueStruct) Set(f float80) {
 // -- String
 
 type StringValue interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   string;
        Set(string);
-       Type()  Type;
 }
 
 type stringValueStruct struct {
@@ -485,10 +551,14 @@ func (v *stringValueStruct) Set(s string) {
 // -- Bool
 
 type BoolValue interface {
+       // TODO: Value;
        Kind()  int;
+       Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   bool;
        Set(bool);
-       Type()  Type;
 }
 
 type boolValueStruct struct {
@@ -510,8 +580,12 @@ func (v *boolValueStruct) Set(b bool) {
 // -- Pointer
 
 type PtrValue interface {
+       // TODO: Value;
        Kind()  int;
        Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Sub()   Value;
        Get()   Addr;
        SetSub(Value);
@@ -547,8 +621,12 @@ func ptrCreator(typ Type, addr Addr) Value {
 // Slices and arrays are represented by the same interface.
 
 type ArrayValue interface {
+       // TODO: Value;
        Kind()  int;
        Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        IsSlice()       bool;
        Len()   int;
        Cap() int;
@@ -681,8 +759,12 @@ func arrayCreator(typ Type, addr Addr) Value {
 // -- Map      TODO: finish and test
 
 type MapValue interface {
+       // TODO: Value;
        Kind()  int;
        Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Len()   int;
        Elem(key Value) Value;
 }
@@ -707,8 +789,11 @@ func (v *mapValueStruct) Elem(key Value) Value {
 // -- Chan
 
 type ChanValue interface {
+       // TODO: Value;
        Kind()  int;
        Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
 }
 
 type chanValueStruct struct {
@@ -722,8 +807,12 @@ func chanCreator(typ Type, addr Addr) Value {
 // -- Struct
 
 type StructValue interface {
+       // TODO: Value;
        Kind()  int;
        Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Len()   int;
        Field(i int)    Value;
 }
@@ -757,8 +846,12 @@ func structCreator(typ Type, addr Addr) Value {
 // -- Interface
 
 type InterfaceValue interface {
+       // TODO: Value;
        Kind()  int;
        Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
+
        Get()   interface {};
 }
 
@@ -777,8 +870,11 @@ func interfaceCreator(typ Type, addr Addr) Value {
 // -- Func
 
 type FuncValue interface {
+       // TODO: Value;
        Kind()  int;
        Type()  Type;
+       Addr()  Addr;
+       Interface()     interface {};
 }
 
 type funcValueStruct struct {
@@ -860,7 +956,7 @@ func NewSliceValue(typ ArrayType, len, cap int) ArrayValue {
        array.len = uint32(len);
        array.cap = uint32(cap);
 
-       return newValueAddr(typ, Addr(array));
+       return newValueAddr(typ, Addr(array)).(ArrayValue);
 }
 
 // Works on both slices and arrays
index 6e769e98cb24573ad43337b97f87bc7b72921d22..b48110819ba69214842fdf77196eabe20fa3da54 100644 (file)
@@ -126,7 +126,7 @@ func put(dat item, out *dch){
 func get(in *dch) *rat {
        seqno++;
        in.req <- seqno;
-       return <-in.dat;
+       return (<-in.dat).(*rat);
 }
 
 // Get one item from each of n demand channels
@@ -332,9 +332,9 @@ func Add(U, V PS) PS{
                for {
                        <-Z.req;
                        uv = get2(U,V);
-                       switch end(uv[0])+2*end(uv[1]) {
+                       switch end(uv[0].(*rat))+2*end(uv[1].(*rat)) {
                        case 0:
-                               Z.dat <- add(uv[0], uv[1]);
+                               Z.dat <- add(uv[0].(*rat), uv[1].(*rat));
                        case 1:
                                Z.dat <- uv[1];
                                copy(V,Z);
@@ -448,13 +448,13 @@ func Mul(U, V PS) PS{
        go func(U, V, Z PS){
                <-Z.req;
                uv := get2(U,V);
-               if end(uv[0])!=0 || end(uv[1]) != 0 {
+               if end(uv[0].(*rat))!=0 || end(uv[1].(*rat)) != 0 {
                        Z.dat <- finis;
                } else {
-                       Z.dat <- mul(uv[0],uv[1]);
+                       Z.dat <- mul(uv[0].(*rat),uv[1].(*rat));
                        UU := Split(U);
                        VV := Split(V);
-                       W := Add(Cmul(uv[0],VV[0]),Cmul(uv[1],UU[0]));
+                       W := Add(Cmul(uv[0].(*rat),VV[0]),Cmul(uv[1].(*rat),UU[0]));
                        <-Z.req;
                        Z.dat <- get(W);
                        copy(Add(W,Mul(UU[1],VV[1])),Z);
index 16300502b88e3a3430164d371059ce16a03a2005..acc295d51aad46b833fc8164e3370634d5f81ad5 100644 (file)
@@ -46,7 +46,7 @@ func main() {
        v.Insert(i0);
        for i := 0; i < v.nelem; i++ {
                var x *I;
-               x = v.At(i);
+               x = v.At(i).(*I);
                print(i, " ", x.val, "\n");  // prints correct list
        }
        for i := 0; i < v.nelem; i++ {
index 0ed5d07082f6d78b601e657b612bf9b1bfce361a..c8a2272c23644c5550deea8f250e3f9d2269c9fc 100644 (file)
@@ -23,10 +23,7 @@ type TStruct struct {
 }
 
 func (s *TStruct) field(i int) *TStruct {
-       // works if we say
-       //      t := s.fields.At(i);
-       //      return t;
-       return s.fields.At(i);
+       return s.fields.At(i).(*TStruct);
 }
 
 func main() {
index 296e9e6d6d45888d24cce16b7d74c1bc7c975aae..e3d8ff66bb502d0403975b4c972472f28dc1605f 100644 (file)
@@ -17,5 +17,5 @@ var   i2      I2;
 func
 main()
 {
-       i2 = e();       // bug089.go:16: fatal error: agen_inter i2i
+       i2 = e().(I2);  // bug089.go:16: fatal error: agen_inter i2i
 }
index ea75260cf28c3b54a328b126d70c69cd7cba05f1..14bd07692637e360f4587c8666bbe6c5bc485fb3 100644 (file)
@@ -11,10 +11,10 @@ func foo2(i int32) int32 { return i }
 func main() {
   var i I;
   i = 1;
-  var v1 int = i;
+  var v1 = i.(int);
   if foo1(v1) != 1 { panicln(1) }
-  var v2 int32 = int32(i.(int));
+  var v2 = int32(i.(int));
   if foo2(v2) != 1 { panicln(2) }
-  var v3 int32 = i; // This implicit type conversion should fail at runtime.
+  var v3 = i.(int32); // This type conversion should fail at runtime.
   if foo2(v3) != 1 { panicln(3) }
 }
index 1db033887f30c3073cd2eb933c924cfbb8a02d17..53676787ff6734355049f28700ccf5ec67967359 100644 (file)
@@ -17,7 +17,7 @@ func main() {
        var i I;
        var e interface {};
        e = s;
-       i = e;
+       i = e.(I);
 }
 
 // hide S down here to avoid static warning
index 2e273ddddb5a614222129dd3e289d3bdf3c3ecb3..86036a778bed70542b89968d63468e56ccd2b28d 100644 (file)
@@ -12,10 +12,21 @@ var t *T
 type I interface { M() }
 var i I
 
+type I2 interface { M(); N(); }
+var i2 I2;
+
+var e interface { };
+
 func main() {
+       e = t;  // ok
+       t = e;  // ERROR "need explicit"
+
        // neither of these can work,
        // because i has an extra method
        // that t does not, so i cannot contain a t.
-       i = t;  // ERROR "missing|incompatible"
-       t = i;  // ERROR "missing|incompatible"
+       i = t;  // ERROR "missing|incompatible|is not"
+       t = i;  // ERROR "missing|incompatible|is not"
+
+       i = i2; // ok
+       i2 = i; // ERROR "need explicit"
 }
index f0c9f4ec2bc239cb003f2f8e805c7251603b1e78..8f4641e81162411c0a4e20e8775ea50a4ff23a92 100644 (file)
@@ -214,7 +214,7 @@ main()
 
        // run it thru an interface
        i = s;
-       s = i;
+       s = i.(*S);
 
        // same as t3
        if s.test1() != s.a1 { panicln("t4", 1) }
index 05eea395bbecf82c5eabe983e6b1f88e1975dfe8..c6b982fe14d56dd9c0f6766703c426fc8eb17367 100644 (file)
@@ -85,21 +85,21 @@ main()
        u32 = 4455;     ia[11] = u32;
        u64 = 765432;   ia[12] = u64;
 
-       s = ia[0]     if s != "xxx" { panicln(0,s); }
+       s = ia[0].(string);     if s != "xxx" { panicln(0,s); }
        i32 = int32(ia[1].(int));
                        if i32 != 12345 { panicln(1,i32); }
-       b = ia[2];      if b != true { panicln(2,b); }
+       b = ia[2].(bool);       if b != true { panicln(2,b); }
 
-       s = ia[3]     if s != "now is" { panicln(3,s); }
-       b = ia[4];      if b != false { panicln(4,b); }
+       s = ia[3].(string);     if s != "now is" { panicln(3,s); }
+       b = ia[4].(bool);       if b != false { panicln(4,b); }
 
-       i8 = ia[5];     if i8 != 29 { panicln(5,i8); }
-       i16 = ia[6];    if i16 != 994 { panicln(6,i16); }
-       i32 = ia[7];    if i32 != 3434 { panicln(7,i32); }
-       i64 = ia[8];    if i64 != 1234567 { panicln(8,i64); }
+       i8 = ia[5].(int8);      if i8 != 29 { panicln(5,i8); }
+       i16 = ia[6].(int16);    if i16 != 994 { panicln(6,i16); }
+       i32 = ia[7].(int32);    if i32 != 3434 { panicln(7,i32); }
+       i64 = ia[8].(int64);    if i64 != 1234567 { panicln(8,i64); }
 
-       u8 = ia[9];     if u8 != 12 { panicln(5,u8); }
-       u16 = ia[10]  if u16 != 799 { panicln(6,u16); }
-       u32 = ia[11]  if u32 != 4455 { panicln(7,u32); }
-       u64 = ia[12]  if u64 != 765432 { panicln(8,u64); }
+       u8 = ia[9].(uint8);     if u8 != 12 { panicln(5,u8); }
+       u16 = ia[10].(uint16);  if u16 != 799 { panicln(6,u16); }
+       u32 = ia[11].(uint32);  if u32 != 4455 { panicln(7,u32); }
+       u64 = ia[12].(uint64);  if u64 != 765432 { panicln(8,u64); }
 }
index 97db89316843a2638e433610650b7d6fbfa86e1b..876d94128dc3cfc6debd25d462f9c5e1e472387d 100644 (file)
@@ -49,16 +49,16 @@ main()
        if s.g() != 6 { panic(12); }
 
        i1 = s;         // convert S to I1
-       i2 = i1;        // convert I1 to I2
+       i2 = i1.(I2);   // convert I1 to I2
 
        // call interface
        if i1.f() != 5 { panic(21); }
        if i2.f() != 5 { panic(22); }
        if i2.g() != 6 { panic(23); }
 
-       g = i1;         // convert I1 to S
+       g = i1.(*S);            // convert I1 to S
        if g != s { panic(31); }
 
-       g = i2;         // convert I2 to S
+       g = i2.(*S);            // convert I2 to S
        if g != s { panic(32); }
 }
index 189fcf43ca19bd5ed13d667c159b3419cfe5b581..b5cbcd72bf99506e6118411f71f9e3f899c0469e 100644 (file)
@@ -299,7 +299,7 @@ func (P *Parser) parseIdentList() AST.Expr {
                        x = last;
                } else {
                        last.Y = P.newBinaryExpr(pos, Scanner.COMMA, last.Y, y);
-                       last = last.Y;
+                       last = last.Y.(*AST.BinaryExpr);
                }
        }
 
@@ -987,7 +987,7 @@ func (P *Parser) parseCompositeElements() AST.Expr {
                                x = last;
                        } else {
                                last.Y = P.newBinaryExpr(pos, Scanner.COMMA, last.Y, y);
-                               last = last.Y;
+                               last = last.Y.(*AST.BinaryExpr);
                        }
 
                        if P.tok == Scanner.COMMA {