| ... | ... | @@ -2153,3 +2153,26 @@ test "align 1 struct parameter dereferenced and returned" { |
| 2153 | 2153 | .little => try expect(s.a == 0x05040302), |
| 2154 | 2154 | } |
| 2155 | 2155 | } |
| 2156 | |
| 2157 | test "avoid unused field function body compile error" { |
| 2158 | const Case = struct { |
| 2159 | const This = @This(); |
| 2160 | |
| 2161 | const S = struct { |
| 2162 | a: usize = 1, |
| 2163 | b: fn () void = This.functionThatDoesNotCompile, |
| 2164 | }; |
| 2165 | |
| 2166 | const s: S = .{}; |
| 2167 | |
| 2168 | fn entry() usize { |
| 2169 | return s.a; |
| 2170 | } |
| 2171 | |
| 2172 | pub fn functionThatDoesNotCompile() void { |
| 2173 | @compileError("told you so"); |
| 2174 | } |
| 2175 | }; |
| 2176 | |
| 2177 | try expect(Case.entry() == 1); |
| 2178 | } |