| author | |
| committer | |
| log | 3eb29f15f537ee79df8f2c4afa0db94ce6137d4c |
| tree | 39c9681be2adbdf7f7022203c842037b5e90f373 |
| parent | 90f2a8d9c5885cdb302757244a5bb2971fdbabe0 |
| parent | 8937f18a6f8496e011b13cb086b7948b5f1d540e |
| signature |
std.json: fix compile error for comptime fields4 files changed, 15 insertions(+), 11 deletions(-)
lib/std/json.zig+1-1| ... | ... | @@ -1766,7 +1766,7 @@ fn parseInternal( |
| 1766 | 1766 | } |
| 1767 | 1767 | } |
| 1768 | 1768 | if (field.is_comptime) { |
| 1769 | if (!try parsesTo(field.field_type, field.default_value.?, tokens, child_options)) { | |
| 1769 | if (!try parsesTo(field.field_type, @ptrCast(*const field.field_type, field.default_value.?).*, tokens, child_options)) { | |
| 1770 | 1770 | return error.UnexpectedValue; |
| 1771 | 1771 | } |
| 1772 | 1772 | } else { |
lib/std/testing.zig+2| ... | ... | @@ -466,6 +466,8 @@ test { |
| 466 | 466 | pub fn refAllDecls(comptime T: type) void { |
| 467 | 467 | if (!builtin.is_test) return; |
| 468 | 468 | inline for (comptime std.meta.declarations(T)) |decl| { |
| 469 | if (decl.is_pub and @typeInfo(@TypeOf(@field(T, decl.name))) == .Struct) | |
| 470 | _ = @hasDecl(@field(T, decl.name), "foo"); | |
| 469 | 471 | _ = decl; |
| 470 | 472 | } |
| 471 | 473 | } |
lib/std/zig/c_translation.zig+1-1| ... | ... | @@ -166,7 +166,7 @@ pub fn sizeof(target: anytype) usize { |
| 166 | 166 | const array_info = @typeInfo(ptr.child).Array; |
| 167 | 167 | if ((array_info.child == u8 or array_info.child == u16) and |
| 168 | 168 | array_info.sentinel != null and |
| 169 | array_info.sentinel.? == 0) | |
| 169 | @ptrCast(*const array_info.child, array_info.sentinel.?).* == 0) | |
| 170 | 170 | { |
| 171 | 171 | // length of the string plus one for the null terminator. |
| 172 | 172 | return (array_info.len + 1) * @sizeOf(array_info.child); |
lib/std/zig/parser_test.zig+11-9| ... | ... | @@ -585,15 +585,6 @@ test "zig fmt: asm expression with comptime content" { |
| 585 | 585 | ); |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | test "zig fmt: anytype struct field" { | |
| 589 | try testCanonical( | |
| 590 | \\pub const Pointer = struct { | |
| 591 | \\ sentinel: anytype, | |
| 592 | \\}; | |
| 593 | \\ | |
| 594 | ); | |
| 595 | } | |
| 596 | ||
| 597 | 588 | test "zig fmt: array types last token" { |
| 598 | 589 | try testCanonical( |
| 599 | 590 | \\test { |
| ... | ... | @@ -4148,6 +4139,17 @@ test "zig fmt: container doc comments" { |
| 4148 | 4139 | ); |
| 4149 | 4140 | } |
| 4150 | 4141 | |
| 4142 | test "zig fmt: anytype struct field" { | |
| 4143 | try testError( | |
| 4144 | \\pub const Pointer = struct { | |
| 4145 | \\ sentinel: anytype, | |
| 4146 | \\}; | |
| 4147 | \\ | |
| 4148 | , &[_]Error{ | |
| 4149 | .expected_type_expr, | |
| 4150 | }); | |
| 4151 | } | |
| 4152 | ||
| 4151 | 4153 | test "zig fmt: extern without container keyword returns error" { |
| 4152 | 4154 | try testError( |
| 4153 | 4155 | \\const container = extern {}; |