8139c5a516
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
17 lines
387 B
Zig
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);
|
|
}
|
|
|