| 1 | const namespace = struct { |
| 2 | const S = struct {}; |
| 3 | const E = enum {}; |
| 4 | const U = union {}; |
| 5 | const O = opaque {}; |
| 6 | }; |
| 7 | export fn declarationValue() void { |
| 8 | @compileLog(@typeName(namespace.S)); |
| 9 | @compileLog(@typeName(namespace.E)); |
| 10 | @compileLog(@typeName(namespace.U)); |
| 11 | @compileLog(@typeName(namespace.O)); |
| 12 | } |
| 13 | |
| 14 | export fn localVarValue() void { |
| 15 | const S = struct {}; |
| 16 | const E = enum {}; |
| 17 | const U = union {}; |
| 18 | const O = opaque {}; |
| 19 | @compileLog(@typeName(S)); |
| 20 | @compileLog(@typeName(E)); |
| 21 | @compileLog(@typeName(U)); |
| 22 | @compileLog(@typeName(O)); |
| 23 | } |
| 24 | |
| 25 | fn MakeS() type { |
| 26 | return struct {}; |
| 27 | } |
| 28 | fn MakeE() type { |
| 29 | return enum {}; |
| 30 | } |
| 31 | fn MakeU() type { |
| 32 | return union {}; |
| 33 | } |
| 34 | fn MakeO() type { |
| 35 | return opaque {}; |
| 36 | } |
| 37 | |
| 38 | export fn returnValue() void { |
| 39 | @compileLog(@typeName(MakeS())); |
| 40 | @compileLog(@typeName(MakeE())); |
| 41 | @compileLog(@typeName(MakeU())); |
| 42 | @compileLog(@typeName(MakeO())); |
| 43 | } |
| 44 | |
| 45 | const StructInStruct = struct { a: struct { b: u8 } }; |
| 46 | const UnionInStruct = struct { a: union { b: u8 } }; |
| 47 | const StructInUnion = union { a: struct { b: u8 } }; |
| 48 | const UnionInUnion = union { a: union { b: u8 } }; |
| 49 | const InnerStruct = struct { b: u8 }; |
| 50 | const StructInTuple = struct { a: InnerStruct }; |
| 51 | const InnerUnion = union { b: u8 }; |
| 52 | const UnionInTuple = struct { a: InnerUnion }; |
| 53 | |
| 54 | export fn nestedTypes() void { |
| 55 | @compileLog(@typeName(StructInStruct)); |
| 56 | @compileLog(@typeName(UnionInStruct)); |
| 57 | @compileLog(@typeName(StructInUnion)); |
| 58 | @compileLog(@typeName(UnionInUnion)); |
| 59 | @compileLog(@typeName(StructInTuple)); |
| 60 | @compileLog(@typeName(UnionInTuple)); |
| 61 | } |
| 62 | |
| 63 | // error |
| 64 | // |
| 65 | // :8:5: error: found compile log statement |
| 66 | // :19:5: note: also here |
| 67 | // :39:5: note: also here |
| 68 | // :55:5: note: also here |
| 69 | // |
| 70 | //Compile Log Output: |
| 71 | //@as(*const [15:0]u8, "tmp.namespace.S") |
| 72 | //@as(*const [15:0]u8, "tmp.namespace.E") |
| 73 | //@as(*const [15:0]u8, "tmp.namespace.U") |
| 74 | //@as(*const [15:0]u8, "tmp.namespace.O") |
| 75 | //@as(*const [19:0]u8, "tmp.localVarValue.S") |
| 76 | //@as(*const [19:0]u8, "tmp.localVarValue.E") |
| 77 | //@as(*const [19:0]u8, "tmp.localVarValue.U") |
| 78 | //@as(*const [19:0]u8, "tmp.localVarValue.O") |
| 79 | //@as(*const [11:0]u8, "tmp.MakeS()") |
| 80 | //@as(*const [11:0]u8, "tmp.MakeE()") |
| 81 | //@as(*const [11:0]u8, "tmp.MakeU()") |
| 82 | //@as(*const [11:0]u8, "tmp.MakeO()") |
| 83 | //@as(*const [18:0]u8, "tmp.StructInStruct") |
| 84 | //@as(*const [17:0]u8, "tmp.UnionInStruct") |
| 85 | //@as(*const [17:0]u8, "tmp.StructInUnion") |
| 86 | //@as(*const [16:0]u8, "tmp.UnionInUnion") |
| 87 | //@as(*const [17:0]u8, "tmp.StructInTuple") |
| 88 | //@as(*const [16:0]u8, "tmp.UnionInTuple") |