diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-04-24 22:31:53 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-04-24 22:31:53 -0400 |
| commit | fb2acaff067dd6b385de7f2bd2726bdfebbf841f (patch) | |
| tree | 1dce5178adc5066eba68510d36baed06575aad0a /test/compile_errors.zig | |
| parent | 733c547a65b005338c89e3b6a6cb6e817bee632b (diff) | |
| download | zig-fb2acaff067dd6b385de7f2bd2726bdfebbf841f.tar.gz zig-fb2acaff067dd6b385de7f2bd2726bdfebbf841f.zip | |
`@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
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 0d30bd7175..60d1a9ac89 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -3,6 +3,15 @@ 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) { \\ return struct{ x: T }; |
