| author | |
| committer | |
| log | 7ec2261dbf7a85f5c215f2dac22b80fca7de1e0f |
| tree | b8faff85307df51c3a91cd6c46ec432ba9e175d0 |
| parent | 804b82b6e82b938eaa736fc90442dd4fd552717e |
In stage1, this behavior was allowed (by accident?) and also
accidentally exercised by the behavior test changed in this commit. In
discussion on Discord, Andrew decided this should not be allowed in
stage2 since there is currently on real world reason to allow this
strange edge case.
I've added the compiler test to solidify that this behavior should NOT
occur and updated the behavior test to the new valid semantics.2 files changed, 14 insertions(+), 1 deletions(-)
test/behavior/bugs/6456.zig+1-1| ... | ... | @@ -19,7 +19,7 @@ test "issue 6456" { |
| 19 | 19 | .alignment = 0, |
| 20 | 20 | .name = name, |
| 21 | 21 | .field_type = usize, |
| 22 | .default_value = @as(?usize, null), | |
| 22 | .default_value = &@as(?usize, null), | |
| 23 | 23 | .is_comptime = false, |
| 24 | 24 | }}; |
| 25 | 25 | } |
test/stage2/llvm.zig+13| ... | ... | @@ -422,4 +422,17 @@ pub fn addCases(ctx: *TestContext) !void { |
| 422 | 422 | \\} |
| 423 | 423 | , ""); |
| 424 | 424 | } |
| 425 | ||
| 426 | { | |
| 427 | // This worked in stage1 and we expressly do not want this to work in stage2 | |
| 428 | var case = ctx.exeUsingLlvmBackend("any typed null to any typed optional", linux_x64); | |
| 429 | case.addError( | |
| 430 | \\pub export fn main() void { | |
| 431 | \\ var a: ?*anyopaque = undefined; | |
| 432 | \\ a = @as(?usize, null); | |
| 433 | \\} | |
| 434 | , &[_][]const u8{ | |
| 435 | ":3:21: error: expected pointer type, found '?usize'", | |
| 436 | }); | |
| 437 | } | |
| 425 | 438 | } |