@sizeOf returns 0 for comptime types
This defines `@sizeOf` to be the runtime size of a type, which means that it is zero for types such as comptime_int, type, and (enum literal). See #2209
This commit is contained in:
@@ -2,6 +2,15 @@ const tests = @import("tests.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"@sizeOf bad type",
|
||||
\\export fn entry() void {
|
||||
\\ _ = @sizeOf(@typeOf(null));
|
||||
\\}
|
||||
,
|
||||
"tmp.zig:2:17: error: no size available for type '(null)'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"Generic function where return type is self-referenced",
|
||||
\\fn Foo(comptime T: type) Foo(T) {
|
||||
|
||||
Reference in New Issue
Block a user