| ... | ... | @@ -103,6 +103,37 @@ const Enum = enum { |
| 103 | 103 | } |
| 104 | 104 | }; |
| 105 | 105 | |
| 106 | test "implicitly cast indirect pointer to maybe-indirect pointer" { |
| 107 | const S = struct { |
| 108 | const Self = this; |
| 109 | x: u8, |
| 110 | fn constConst(p: &const &const Self) u8 { |
| 111 | return (*p).x; |
| 112 | } |
| 113 | fn maybeConstConst(p: ?&const &const Self) u8 { |
| 114 | return (*??p).x; |
| 115 | } |
| 116 | fn constConstConst(p: &const &const &const Self) u8 { |
| 117 | return (**p).x; |
| 118 | } |
| 119 | fn maybeConstConstConst(p: ?&const &const &const Self) u8 { |
| 120 | return (**??p).x; |
| 121 | } |
| 122 | }; |
| 123 | const s = S { .x = 42 }; |
| 124 | const p = &s; |
| 125 | const q = &p; |
| 126 | const r = &q; |
| 127 | assert(42 == S.constConst(p)); |
| 128 | assert(42 == S.constConst(q)); |
| 129 | assert(42 == S.maybeConstConst(p)); |
| 130 | assert(42 == S.maybeConstConst(q)); |
| 131 | assert(42 == S.constConstConst(q)); |
| 132 | assert(42 == S.constConstConst(r)); |
| 133 | assert(42 == S.maybeConstConstConst(q)); |
| 134 | assert(42 == S.maybeConstConstConst(r)); |
| 135 | } |
| 136 | |
| 106 | 137 | test "explicit cast from integer to error type" { |
| 107 | 138 | testCastIntToErr(error.ItBroke); |
| 108 | 139 | comptime testCastIntToErr(error.ItBroke); |