| ... | ... | @@ -0,0 +1,50 @@ |
| 1 | const std = @import("std"); |
| 2 | |
| 3 | const Error = error{Something}; |
| 4 | |
| 5 | fn next() Error!void { |
| 6 | return; |
| 7 | } |
| 8 | |
| 9 | fn parse(comptime T: type, allocator: std.mem.Allocator) !void { |
| 10 | parseFree(T, undefined, allocator); |
| 11 | _ = (try next()) != null; |
| 12 | } |
| 13 | |
| 14 | fn parseFree(comptime T: type, value: T, allocator: std.mem.Allocator) void { |
| 15 | switch (@typeInfo(T)) { |
| 16 | .Struct => |structInfo| { |
| 17 | inline for (structInfo.fields) |field| { |
| 18 | if (!field.is_comptime) |
| 19 | parseFree(field.field_type, undefined, allocator); |
| 20 | } |
| 21 | }, |
| 22 | .Pointer => |ptrInfo| { |
| 23 | switch (ptrInfo.size) { |
| 24 | .One => { |
| 25 | parseFree(ptrInfo.child, value.*, allocator); |
| 26 | }, |
| 27 | .Slice => { |
| 28 | for (value) |v| |
| 29 | parseFree(ptrInfo.child, v, allocator); |
| 30 | }, |
| 31 | else => unreachable, |
| 32 | } |
| 33 | }, |
| 34 | else => unreachable, |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | pub export fn entry() void { |
| 39 | const allocator = std.testing.allocator_instance.allocator(); |
| 40 | _ = parse(std.StringArrayHashMap(bool), allocator) catch return; |
| 41 | } |
| 42 | |
| 43 | // error |
| 44 | // backend=llvm |
| 45 | // |
| 46 | // :11:22: error: comparison of 'void' with null |
| 47 | // :25:51: error: unable to resolve comptime value |
| 48 | // :25:51: error: unable to resolve comptime value |
| 49 | // :25:51: error: unable to resolve comptime value |
| 50 | // :25:51: error: unable to resolve comptime value |