zig/test/cases/bugs/726.zig
Jimmi Holst Christensen 8139c5a516
New Zig formal grammar (#1685)
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
2018-11-13 05:08:37 -08:00

17 lines
387 B
Zig

const assert = @import("std").debug.assert;
test "@ptrCast from const to nullable" {
const c: u8 = 4;
var x: ?*const u8 = @ptrCast(?*const u8, &c);
assert(x.?.* == 4);
}
test "@ptrCast from var in empty struct to nullable" {
const container = struct {
var c: u8 = 4;
};
var x: ?*const u8 = @ptrCast(?*const u8, &container.c);
assert(x.?.* == 4);
}