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 {
177177 .Float,
178178 .Null,
179179 => 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))})),
181181 }
182182}
183183
lib/std/fmt.zig+1-1
......@@ -199,7 +199,7 @@ pub fn format(
199199 switch (missing_count) {
200200 0 => unreachable,
201201 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 ++ "'"),
203203 }
204204 }
205205}
lib/std/testing.zig+1-1
......@@ -765,7 +765,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime
765765 }
766766 const expected_args_tuple_len = fn_args_fields.len - 1;
767767 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}));
769769 }
770770
771771 // 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(
84558455 operand_node: Ast.Node.Index,
84568456 tag: Zir.Inst.Tag,
84578457) InnerError!Zir.Inst.Ref {
8458 const prev_force_comptime = gz.force_comptime;
8459 defer gz.force_comptime = prev_force_comptime;
8460
84588461 switch (tag) {
84598462 .tag_name, .error_name, .ptr_to_int => try emitDbgNode(gz, node),
8463 .compile_error => gz.force_comptime = true,
84608464 else => {},
84618465 }
84628466 const operand = try expr(gz, scope, operand_ri, operand_node);