authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-12-04 15:03:32+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-12-07 14:48:24+02:00
log92f1a29c4082817f11e12ff58bd4fdb5fffb8608
treeeec9d9d740422b004a0062162c4772a82a402a72
parent1310ef75777209f061bfd61473db75911538b5ff

AstGen: make `@compileError` operand implicitly comptime

This matches the language reference.

4 files changed, 7 insertions(+), 3 deletions(-)

lib/std/build/OptionsStep.zig+1-1
...@@ -177,7 +177,7 @@ fn printLiteral(out: anytype, val: anytype, indent: u8) !void {...@@ -177,7 +177,7 @@ fn printLiteral(out: anytype, val: anytype, indent: u8) !void {
177 .Float,177 .Float,
178 .Null,178 .Null,
179 => try out.print("{any}", .{val}),179 => try out.print("{any}", .{val}),
180 else => @compileError(comptime std.fmt.comptimePrint("`{s}` are not yet supported as build options", .{@tagName(@typeInfo(T))})),180 else => @compileError(std.fmt.comptimePrint("`{s}` are not yet supported as build options", .{@tagName(@typeInfo(T))})),
181 }181 }
182}182}
183183
lib/std/fmt.zig+1-1
...@@ -199,7 +199,7 @@ pub fn format(...@@ -199,7 +199,7 @@ pub fn format(
199 switch (missing_count) {199 switch (missing_count) {
200 0 => unreachable,200 0 => unreachable,
201 1 => @compileError("unused argument in '" ++ fmt ++ "'"),201 1 => @compileError("unused argument in '" ++ fmt ++ "'"),
202 else => @compileError((comptime comptimePrint("{d}", .{missing_count})) ++ " unused arguments in '" ++ fmt ++ "'"),202 else => @compileError(comptimePrint("{d}", .{missing_count}) ++ " unused arguments in '" ++ fmt ++ "'"),
203 }203 }
204 }204 }
205}205}
lib/std/testing.zig+1-1
...@@ -765,7 +765,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime...@@ -765,7 +765,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime
765 }765 }
766 const expected_args_tuple_len = fn_args_fields.len - 1;766 const expected_args_tuple_len = fn_args_fields.len - 1;
767 if (extra_args.len != expected_args_tuple_len) {767 if (extra_args.len != expected_args_tuple_len) {
768 @compileError("The provided function expects " ++ (comptime std.fmt.comptimePrint("{d}", .{expected_args_tuple_len})) ++ " extra arguments, but the provided tuple contains " ++ (comptime std.fmt.comptimePrint("{d}", .{extra_args.len})));768 @compileError("The provided function expects " ++ std.fmt.comptimePrint("{d}", .{expected_args_tuple_len}) ++ " extra arguments, but the provided tuple contains " ++ std.fmt.comptimePrint("{d}", .{extra_args.len}));
769 }769 }
770770
771 // Setup the tuple that will actually be used with @call (we'll need to insert771 // Setup the tuple that will actually be used with @call (we'll need to insert
src/AstGen.zig+4
...@@ -8455,8 +8455,12 @@ fn simpleUnOp(...@@ -8455,8 +8455,12 @@ fn simpleUnOp(
8455 operand_node: Ast.Node.Index,8455 operand_node: Ast.Node.Index,
8456 tag: Zir.Inst.Tag,8456 tag: Zir.Inst.Tag,
8457) InnerError!Zir.Inst.Ref {8457) InnerError!Zir.Inst.Ref {
8458 const prev_force_comptime = gz.force_comptime;
8459 defer gz.force_comptime = prev_force_comptime;
8460
8458 switch (tag) {8461 switch (tag) {
8459 .tag_name, .error_name, .ptr_to_int => try emitDbgNode(gz, node),8462 .tag_name, .error_name, .ptr_to_int => try emitDbgNode(gz, node),
8463 .compile_error => gz.force_comptime = true,
8460 else => {},8464 else => {},
8461 }8465 }
8462 const operand = try expr(gz, scope, operand_ri, operand_node);8466 const operand = try expr(gz, scope, operand_ri, operand_node);