diff --git a/gnovm/pkg/gnolang/preprocess.go b/gnovm/pkg/gnolang/preprocess.go index 6e82786b318..78b11a4ebc5 100644 --- a/gnovm/pkg/gnolang/preprocess.go +++ b/gnovm/pkg/gnolang/preprocess.go @@ -2352,6 +2352,10 @@ func preprocess1(store Store, ctx BlockNode, n Node) Node { // } *dst = *dt2 } + case PrimitiveType: + dst = tmp.(PrimitiveType) + case *PointerType: + *dst = *(tmp.(*PointerType)) default: panic(fmt.Sprintf("unexpected type declaration type %v", reflect.TypeOf(dst))) @@ -4283,9 +4287,6 @@ func tryPredefine(store Store, last BlockNode, d Decl) (un Name) { // predefineNow preprocessed dependent types. panic("should not happen") } - } else { - // all names are declared types. - panic("should not happen") } } else if idx, ok := UverseNode().GetLocalIndex(tx.Name); ok { // uverse name diff --git a/gnovm/tests/files/type40.gno b/gnovm/tests/files/type40.gno new file mode 100644 index 00000000000..65210798007 --- /dev/null +++ b/gnovm/tests/files/type40.gno @@ -0,0 +1,46 @@ +package main + +type ( + // PrimitiveType + Number = int32 + Number2 = Number + + // PointerType + Pointer = *int32 + Pointer2 = Pointer + + // Interface + Interface = interface{} + Interface2 = Interface + + // S + Struct = struct{Name string} + Struct2 = Struct +) + +func fNumber(n Number) { println(n) } +func fPointer(p Pointer) { println(*p) } +func fInterface(i Interface) { println(i) } +func fStruct(s Struct) { println(s.Name) } + +func main() { + var n Number2 = 5 + fNumber(n) + + var num int32 = 6 + var p Pointer2 = &num + fPointer(p) + + var i Interface2 + i = 7 + fInterface(i) + + var s Struct2 = Struct2{Name: "yo"} + fStruct(s) +} + +// Output: +// 5 +// 6 +// 7 +// yo \ No newline at end of file