Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ast.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2424,7 +2424,7 @@ fn renderNullSentinelArrayType(c: *Context, len: u64, elem_type: Node) !NodeInde
fn addSemicolonIfNeeded(c: *Context, node: Node) !void {
switch (node.tag()) {
.warning => unreachable,
.var_decl, .var_simple, .arg_redecl, .alias, .block, .empty_block, .block_single, .@"switch", .wrapped_local, .mut_str => {},
.static_assert, .var_decl, .var_simple, .arg_redecl, .alias, .block, .empty_block, .block_single, .@"switch", .wrapped_local, .mut_str => {},
.while_true => {
const payload = node.castTag(.while_true).?.data;
return addSemicolonIfNotBlock(c, payload);
Expand Down
9 changes: 9 additions & 0 deletions test/cases/translate/_Static_assert.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
_Static_assert(1 == 1, "");

void my_function() {
_Static_assert(2 + 2 * 2 == 6, "Math is hard");
}

// translate
//
// comptime {
// if (!(@as(c_int, 1) == @as(c_int, 1))) @compileError("static assertion failed \"\"");
// }
// pub export fn my_function() void {
// comptime {
// if (!((@as(c_int, 2) + (@as(c_int, 2) * @as(c_int, 2))) == @as(c_int, 6))) @compileError("static assertion failed \"Math is hard\"");
// }
// }
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ void somefunc(void) {
// y = 1;
// comptime {
// if (!(@as(c_int, 1) != 0)) @compileError("static assertion failed");
// };
// }
// }
// }