authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-10-12 05:26:11-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-10-12 05:26:11-04:00
log7ce1ee1bce4d9ca05a647c9c390c6525be0b6362
treea65ac3b2e1f252a1cc7c5efa6e70f0320034e823
parentbec40a89c21009ea7f2c41362cc13d27f065b43e
parent8e2aaf6aed5213736f6cbbb374098e2394f19429
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #13081 from r00ster91/docs

fix(text): hyphenation and other fixes

39 files changed, 187 insertions(+), 186 deletions(-)

doc/langref.html.in+2-2
...@@ -8171,7 +8171,7 @@ fn func(y: *i32) void {...@@ -8171,7 +8171,7 @@ fn func(y: *i32) void {
8171 {#header_open|@mulAdd#}8171 {#header_open|@mulAdd#}
8172 <pre>{#syntax#}@mulAdd(comptime T: type, a: T, b: T, c: T) T{#endsyntax#}</pre>8172 <pre>{#syntax#}@mulAdd(comptime T: type, a: T, b: T, c: T) T{#endsyntax#}</pre>
8173 <p>8173 <p>
8174 Fused multiply add, similar to {#syntax#}(a * b) + c{#endsyntax#}, except8174 Fused multiply-add, similar to {#syntax#}(a * b) + c{#endsyntax#}, except
8175 only rounds once, and is thus more accurate.8175 only rounds once, and is thus more accurate.
8176 </p>8176 </p>
8177 <p>8177 <p>
...@@ -9306,7 +9306,7 @@ pub const FloatMode = enum {...@@ -9306,7 +9306,7 @@ pub const FloatMode = enum {
9306 <li>Assume the arguments and result are not +/-Inf. Optimizations are required to retain defined behavior over +/-Inf, but the value of the result is undefined.</li>9306 <li>Assume the arguments and result are not +/-Inf. Optimizations are required to retain defined behavior over +/-Inf, but the value of the result is undefined.</li>
9307 <li>Treat the sign of a zero argument or result as insignificant.</li>9307 <li>Treat the sign of a zero argument or result as insignificant.</li>
9308 <li>Use the reciprocal of an argument rather than perform division.</li>9308 <li>Use the reciprocal of an argument rather than perform division.</li>
9309 <li>Perform floating-point contraction (e.g. fusing a multiply followed by an addition into a fused multiply-and-add).</li>9309 <li>Perform floating-point contraction (e.g. fusing a multiply followed by an addition into a fused multiply-add).</li>
9310 <li>Perform algebraically equivalent transformations that may change results in floating point (e.g. reassociate).</li>9310 <li>Perform algebraically equivalent transformations that may change results in floating point (e.g. reassociate).</li>
9311 </ul>9311 </ul>
9312 This is equivalent to <code>-ffast-math</code> in GCC.9312 This is equivalent to <code>-ffast-math</code> in GCC.
lib/std/bit_set.zig+3-3
...@@ -23,7 +23,7 @@...@@ -23,7 +23,7 @@
23//! size. The interfaces of these two types match exactly, except for fields.23//! size. The interfaces of these two types match exactly, except for fields.
24//!24//!
25//! DynamicBitSet:25//! DynamicBitSet:
26//! A bit set with runtime known size, backed by an allocated slice26//! A bit set with runtime-known size, backed by an allocated slice
27//! of usize.27//! of usize.
28//!28//!
29//! DynamicBitSetUnmanaged:29//! DynamicBitSetUnmanaged:
...@@ -515,7 +515,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {...@@ -515,7 +515,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
515 };515 };
516}516}
517517
518/// A bit set with runtime known size, backed by an allocated slice518/// A bit set with runtime-known size, backed by an allocated slice
519/// of usize. The allocator must be tracked externally by the user.519/// of usize. The allocator must be tracked externally by the user.
520pub const DynamicBitSetUnmanaged = struct {520pub const DynamicBitSetUnmanaged = struct {
521 const Self = @This();521 const Self = @This();
...@@ -843,7 +843,7 @@ pub const DynamicBitSetUnmanaged = struct {...@@ -843,7 +843,7 @@ pub const DynamicBitSetUnmanaged = struct {
843 }843 }
844};844};
845845
846/// A bit set with runtime known size, backed by an allocated slice846/// A bit set with runtime-known size, backed by an allocated slice
847/// of usize. Thin wrapper around DynamicBitSetUnmanaged which keeps847/// of usize. Thin wrapper around DynamicBitSetUnmanaged which keeps
848/// track of the allocator instance.848/// track of the allocator instance.
849pub const DynamicBitSet = struct {849pub const DynamicBitSet = struct {
lib/std/enums.zig+1-1
...@@ -696,7 +696,7 @@ pub fn IndexedArray(comptime I: type, comptime V: type, comptime Ext: fn (type)...@@ -696,7 +696,7 @@ pub fn IndexedArray(comptime I: type, comptime V: type, comptime Ext: fn (type)
696}696}
697697
698/// Verifies that a type is a valid Indexer, providing a helpful698/// Verifies that a type is a valid Indexer, providing a helpful
699/// compile error if not. An Indexer maps a comptime known set699/// compile error if not. An Indexer maps a comptime-known set
700/// of keys to a dense set of zero-based indices.700/// of keys to a dense set of zero-based indices.
701/// The indexer interface must look like this:701/// The indexer interface must look like this:
702/// ```702/// ```
lib/std/fmt.zig+1-1
...@@ -29,7 +29,7 @@ pub const FormatOptions = struct {...@@ -29,7 +29,7 @@ pub const FormatOptions = struct {
29/// If `writer` returns an error, the error is returned from `format` and29/// If `writer` returns an error, the error is returned from `format` and
30/// `writer` is not called again.30/// `writer` is not called again.
31///31///
32/// The format string must be comptime known and may contain placeholders following32/// The format string must be comptime-known and may contain placeholders following
33/// this format:33/// this format:
34/// `{[argument][specifier]:[fill][alignment][width].[precision]}`34/// `{[argument][specifier]:[fill][alignment][width].[precision]}`
35///35///
lib/std/math.zig+4-3
...@@ -786,14 +786,14 @@ fn testOverflow() !void {...@@ -786,14 +786,14 @@ fn testOverflow() !void {
786 try testing.expect((shlExact(i32, 0b11, 4) catch unreachable) == 0b110000);786 try testing.expect((shlExact(i32, 0b11, 4) catch unreachable) == 0b110000);
787}787}
788788
789/// Returns the absolute value of x, where x is a value of an integer789/// Returns the absolute value of x, where x is a value of a signed integer type.
790/// type.790/// See also: `absCast`
791pub fn absInt(x: anytype) !@TypeOf(x) {791pub fn absInt(x: anytype) !@TypeOf(x) {
792 const T = @TypeOf(x);792 const T = @TypeOf(x);
793 comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt793 comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt
794 comptime assert(@typeInfo(T).Int.signedness == .signed); // must pass a signed integer to absInt794 comptime assert(@typeInfo(T).Int.signedness == .signed); // must pass a signed integer to absInt
795795
796 if (x == minInt(@TypeOf(x))) {796 if (x == minInt(T)) {
797 return error.Overflow;797 return error.Overflow;
798 } else {798 } else {
799 @setRuntimeSafety(false);799 @setRuntimeSafety(false);
...@@ -1001,6 +1001,7 @@ pub inline fn fabs(value: anytype) @TypeOf(value) {...@@ -1001,6 +1001,7 @@ pub inline fn fabs(value: anytype) @TypeOf(value) {
10011001
1002/// Returns the absolute value of the integer parameter.1002/// Returns the absolute value of the integer parameter.
1003/// Result is an unsigned integer.1003/// Result is an unsigned integer.
1004/// See also: `absInt`
1004pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {1005pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {
1005 .ComptimeInt => comptime_int,1006 .ComptimeInt => comptime_int,
1006 .Int => |int_info| std.meta.Int(.unsigned, int_info.bits),1007 .Int => |int_info| std.meta.Int(.unsigned, int_info.bits),
lib/std/testing.zig+4-4
...@@ -213,8 +213,8 @@ pub fn expectFmt(expected: []const u8, comptime template: []const u8, args: anyt...@@ -213,8 +213,8 @@ pub fn expectFmt(expected: []const u8, comptime template: []const u8, args: anyt
213/// This function is intended to be used only in tests. When the actual value is213/// This function is intended to be used only in tests. When the actual value is
214/// not approximately equal to the expected value, prints diagnostics to stderr214/// not approximately equal to the expected value, prints diagnostics to stderr
215/// to show exactly how they are not equal, then returns a test failure error.215/// to show exactly how they are not equal, then returns a test failure error.
216/// See `math.approxEqAbs` for more informations on the tolerance parameter.216/// See `math.approxEqAbs` for more information on the tolerance parameter.
217/// The types must be floating point.217/// The types must be floating-point.
218pub fn expectApproxEqAbs(expected: anytype, actual: @TypeOf(expected), tolerance: @TypeOf(expected)) !void {218pub fn expectApproxEqAbs(expected: anytype, actual: @TypeOf(expected), tolerance: @TypeOf(expected)) !void {
219 const T = @TypeOf(expected);219 const T = @TypeOf(expected);
220220
...@@ -245,8 +245,8 @@ test "expectApproxEqAbs" {...@@ -245,8 +245,8 @@ test "expectApproxEqAbs" {
245/// This function is intended to be used only in tests. When the actual value is245/// This function is intended to be used only in tests. When the actual value is
246/// not approximately equal to the expected value, prints diagnostics to stderr246/// not approximately equal to the expected value, prints diagnostics to stderr
247/// to show exactly how they are not equal, then returns a test failure error.247/// to show exactly how they are not equal, then returns a test failure error.
248/// See `math.approxEqRel` for more informations on the tolerance parameter.248/// See `math.approxEqRel` for more information on the tolerance parameter.
249/// The types must be floating point.249/// The types must be floating-point.
250pub fn expectApproxEqRel(expected: anytype, actual: @TypeOf(expected), tolerance: @TypeOf(expected)) !void {250pub fn expectApproxEqRel(expected: anytype, actual: @TypeOf(expected), tolerance: @TypeOf(expected)) !void {
251 const T = @TypeOf(expected);251 const T = @TypeOf(expected);
252252
src/Module.zig+2-2
...@@ -3494,7 +3494,7 @@ fn freeExportList(gpa: Allocator, export_list: []*Export) void {...@@ -3494,7 +3494,7 @@ fn freeExportList(gpa: Allocator, export_list: []*Export) void {
3494const data_has_safety_tag = @sizeOf(Zir.Inst.Data) != 8;3494const data_has_safety_tag = @sizeOf(Zir.Inst.Data) != 8;
3495// TODO This is taking advantage of matching stage1 debug union layout.3495// TODO This is taking advantage of matching stage1 debug union layout.
3496// We need a better language feature for initializing a union with3496// We need a better language feature for initializing a union with
3497// a runtime known tag.3497// a runtime-known tag.
3498const Stage1DataLayout = extern struct {3498const Stage1DataLayout = extern struct {
3499 data: [8]u8 align(@alignOf(Zir.Inst.Data)),3499 data: [8]u8 align(@alignOf(Zir.Inst.Data)),
3500 safety_tag: u8,3500 safety_tag: u8,
...@@ -4594,7 +4594,7 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !bool {...@@ -4594,7 +4594,7 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !bool {
4594 const decl_linksection: ?[*:0]const u8 = blk: {4594 const decl_linksection: ?[*:0]const u8 = blk: {
4595 const linksection_ref = decl.zirLinksectionRef();4595 const linksection_ref = decl.zirLinksectionRef();
4596 if (linksection_ref == .none) break :blk null;4596 if (linksection_ref == .none) break :blk null;
4597 const bytes = try sema.resolveConstString(&block_scope, section_src, linksection_ref, "linksection must be comptime known");4597 const bytes = try sema.resolveConstString(&block_scope, section_src, linksection_ref, "linksection must be comptime-known");
4598 if (mem.indexOfScalar(u8, bytes, 0) != null) {4598 if (mem.indexOfScalar(u8, bytes, 0) != null) {
4599 return sema.fail(&block_scope, section_src, "linksection cannot contain null bytes", .{});4599 return sema.fail(&block_scope, section_src, "linksection cannot contain null bytes", .{});
4600 } else if (bytes.len == 0) {4600 } else if (bytes.len == 0) {
src/Sema.zig+116-116
...@@ -50,7 +50,7 @@ comptime_break_inst: Zir.Inst.Index = undefined,...@@ -50,7 +50,7 @@ comptime_break_inst: Zir.Inst.Index = undefined,
50src: LazySrcLoc = .{ .token_offset = 0 },50src: LazySrcLoc = .{ .token_offset = 0 },
51decl_val_table: std.AutoHashMapUnmanaged(Decl.Index, Air.Inst.Ref) = .{},51decl_val_table: std.AutoHashMapUnmanaged(Decl.Index, Air.Inst.Ref) = .{},
52/// When doing a generic function instantiation, this array collects a52/// When doing a generic function instantiation, this array collects a
53/// `Value` object for each parameter that is comptime known and thus elided53/// `Value` object for each parameter that is comptime-known and thus elided
54/// from the generated function. This memory is allocated by a parent `Sema` and54/// from the generated function. This memory is allocated by a parent `Sema` and
55/// owned by the values arena of the Sema owner_decl.55/// owned by the values arena of the Sema owner_decl.
56comptime_args: []TypedValue = &.{},56comptime_args: []TypedValue = &.{},
...@@ -1381,7 +1381,7 @@ fn analyzeBodyInner(...@@ -1381,7 +1381,7 @@ fn analyzeBodyInner(
1381 const extra = sema.code.extraData(Zir.Inst.CondBr, inst_data.payload_index);1381 const extra = sema.code.extraData(Zir.Inst.CondBr, inst_data.payload_index);
1382 const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len];1382 const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len];
1383 const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len];1383 const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len];
1384 const cond = try sema.resolveInstConst(block, cond_src, extra.data.condition, "condition in comptime branch must be comptime known");1384 const cond = try sema.resolveInstConst(block, cond_src, extra.data.condition, "condition in comptime branch must be comptime-known");
1385 const inline_body = if (cond.val.toBool()) then_body else else_body;1385 const inline_body = if (cond.val.toBool()) then_body else else_body;
13861386
1387 try sema.maybeErrorUnwrapCondbr(block, inline_body, extra.data.condition, cond_src);1387 try sema.maybeErrorUnwrapCondbr(block, inline_body, extra.data.condition, cond_src);
...@@ -1399,7 +1399,7 @@ fn analyzeBodyInner(...@@ -1399,7 +1399,7 @@ fn analyzeBodyInner(
1399 const extra = sema.code.extraData(Zir.Inst.CondBr, inst_data.payload_index);1399 const extra = sema.code.extraData(Zir.Inst.CondBr, inst_data.payload_index);
1400 const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len];1400 const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len];
1401 const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len];1401 const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len];
1402 const cond = try sema.resolveInstConst(block, cond_src, extra.data.condition, "condition in comptime branch must be comptime known");1402 const cond = try sema.resolveInstConst(block, cond_src, extra.data.condition, "condition in comptime branch must be comptime-known");
1403 const inline_body = if (cond.val.toBool()) then_body else else_body;1403 const inline_body = if (cond.val.toBool()) then_body else else_body;
1404 const old_runtime_index = block.runtime_index;1404 const old_runtime_index = block.runtime_index;
1405 defer block.runtime_index = old_runtime_index;1405 defer block.runtime_index = old_runtime_index;
...@@ -1421,7 +1421,7 @@ fn analyzeBodyInner(...@@ -1421,7 +1421,7 @@ fn analyzeBodyInner(
1421 const err_union = try sema.resolveInst(extra.data.operand);1421 const err_union = try sema.resolveInst(extra.data.operand);
1422 const is_non_err = try sema.analyzeIsNonErrComptimeOnly(block, operand_src, err_union);1422 const is_non_err = try sema.analyzeIsNonErrComptimeOnly(block, operand_src, err_union);
1423 assert(is_non_err != .none);1423 assert(is_non_err != .none);
1424 const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err, "try operand inside comptime block must be comptime known");1424 const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err, "try operand inside comptime block must be comptime-known");
1425 if (is_non_err_tv.val.toBool()) {1425 if (is_non_err_tv.val.toBool()) {
1426 const err_union_ty = sema.typeOf(err_union);1426 const err_union_ty = sema.typeOf(err_union);
1427 break :blk try sema.analyzeErrUnionPayload(block, src, err_union_ty, err_union, operand_src, false);1427 break :blk try sema.analyzeErrUnionPayload(block, src, err_union_ty, err_union, operand_src, false);
...@@ -1477,7 +1477,7 @@ fn analyzeBodyInner(...@@ -1477,7 +1477,7 @@ fn analyzeBodyInner(
1477 const err_union = try sema.analyzeLoad(block, src, operand, operand_src);1477 const err_union = try sema.analyzeLoad(block, src, operand, operand_src);
1478 const is_non_err = try sema.analyzeIsNonErrComptimeOnly(block, operand_src, err_union);1478 const is_non_err = try sema.analyzeIsNonErrComptimeOnly(block, operand_src, err_union);
1479 assert(is_non_err != .none);1479 assert(is_non_err != .none);
1480 const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err, "try operand inside comptime block must be comptime known");1480 const is_non_err_tv = try sema.resolveInstConst(block, operand_src, is_non_err, "try operand inside comptime block must be comptime-known");
1481 if (is_non_err_tv.val.toBool()) {1481 if (is_non_err_tv.val.toBool()) {
1482 break :blk try sema.analyzeErrUnionPayloadPtr(block, src, operand, false, false);1482 break :blk try sema.analyzeErrUnionPayloadPtr(block, src, operand, false, false);
1483 }1483 }
...@@ -1622,7 +1622,7 @@ fn analyzeAsType(...@@ -1622,7 +1622,7 @@ fn analyzeAsType(
1622) !Type {1622) !Type {
1623 const wanted_type = Type.initTag(.@"type");1623 const wanted_type = Type.initTag(.@"type");
1624 const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src);1624 const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src);
1625 const val = try sema.resolveConstValue(block, src, coerced_inst, "types must be comptime known");1625 const val = try sema.resolveConstValue(block, src, coerced_inst, "types must be comptime-known");
1626 var buffer: Value.ToTypeBuffer = undefined;1626 var buffer: Value.ToTypeBuffer = undefined;
1627 const ty = val.toType(&buffer);1627 const ty = val.toType(&buffer);
1628 return ty.copy(sema.arena);1628 return ty.copy(sema.arena);
...@@ -2067,7 +2067,7 @@ fn analyzeAsAlign(...@@ -2067,7 +2067,7 @@ fn analyzeAsAlign(
2067 src: LazySrcLoc,2067 src: LazySrcLoc,
2068 air_ref: Air.Inst.Ref,2068 air_ref: Air.Inst.Ref,
2069) !u32 {2069) !u32 {
2070 const alignment_big = try sema.analyzeAsInt(block, src, air_ref, align_ty, "alignment must be comptime known");2070 const alignment_big = try sema.analyzeAsInt(block, src, air_ref, align_ty, "alignment must be comptime-known");
2071 const alignment = @intCast(u32, alignment_big); // We coerce to u16 in the prev line.2071 const alignment = @intCast(u32, alignment_big); // We coerce to u16 in the prev line.
2072 try sema.validateAlign(block, src, alignment);2072 try sema.validateAlign(block, src, alignment);
2073 return alignment;2073 return alignment;
...@@ -2741,7 +2741,7 @@ fn zirEnumDecl(...@@ -2741,7 +2741,7 @@ fn zirEnumDecl(
2741 // TODO: if we need to report an error here, use a source location2741 // TODO: if we need to report an error here, use a source location
2742 // that points to this default value expression rather than the struct.2742 // that points to this default value expression rather than the struct.
2743 // But only resolve the source location if we need to emit a compile error.2743 // But only resolve the source location if we need to emit a compile error.
2744 const tag_val = (try sema.resolveInstConst(block, src, tag_val_ref, "enum tag value must be comptime known")).val;2744 const tag_val = (try sema.resolveInstConst(block, src, tag_val_ref, "enum tag value must be comptime-known")).val;
2745 last_tag_val = tag_val;2745 last_tag_val = tag_val;
2746 const copied_tag_val = try tag_val.copy(decl_arena_allocator);2746 const copied_tag_val = try tag_val.copy(decl_arena_allocator);
2747 const gop_val = enum_obj.values.getOrPutAssumeCapacityContext(copied_tag_val, .{2747 const gop_val = enum_obj.values.getOrPutAssumeCapacityContext(copied_tag_val, .{
...@@ -3259,7 +3259,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -3259,7 +3259,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
3259 var ptr_info = alloc_ty.ptrInfo().data;3259 var ptr_info = alloc_ty.ptrInfo().data;
3260 const elem_ty = ptr_info.pointee_type;3260 const elem_ty = ptr_info.pointee_type;
32613261
3262 // Detect if all stores to an `.alloc` were comptime known.3262 // Detect if all stores to an `.alloc` were comptime-known.
3263 ct: {3263 ct: {
3264 var search_index: usize = block.instructions.items.len;3264 var search_index: usize = block.instructions.items.len;
3265 const air_tags = sema.air_instructions.items(.tag);3265 const air_tags = sema.air_instructions.items(.tag);
...@@ -3476,7 +3476,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com...@@ -3476,7 +3476,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
3476 if (var_is_mut) {3476 if (var_is_mut) {
3477 try sema.validateVarType(block, ty_src, final_elem_ty, false);3477 try sema.validateVarType(block, ty_src, final_elem_ty, false);
3478 } else ct: {3478 } else ct: {
3479 // Detect if the value is comptime known. In such case, the3479 // Detect if the value is comptime-known. In such case, the
3480 // last 3 AIR instructions of the block will look like this:3480 // last 3 AIR instructions of the block will look like this:
3481 //3481 //
3482 // %a = constant3482 // %a = constant
...@@ -4383,7 +4383,7 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -4383,7 +4383,7 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
4383 const msg = try sema.errMsg(4383 const msg = try sema.errMsg(
4384 block,4384 block,
4385 src,4385 src,
4386 "values of type '{}' must be comptime known, but operand value is runtime known",4386 "values of type '{}' must be comptime-known, but operand value is runtime-known",
4387 .{elem_ty.fmt(sema.mod)},4387 .{elem_ty.fmt(sema.mod)},
4388 );4388 );
4389 errdefer msg.destroy(sema.gpa);4389 errdefer msg.destroy(sema.gpa);
...@@ -4597,13 +4597,13 @@ fn storeToInferredAllocComptime(...@@ -4597,13 +4597,13 @@ fn storeToInferredAllocComptime(
4597 return;4597 return;
4598 }4598 }
45994599
4600 return sema.failWithNeededComptime(block, src, "value being stored to a comptime variable must be comptime known");4600 return sema.failWithNeededComptime(block, src, "value being stored to a comptime variable must be comptime-known");
4601}4601}
46024602
4603fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {4603fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
4604 const inst_data = sema.code.instructions.items(.data)[inst].un_node;4604 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
4605 const src = inst_data.src();4605 const src = inst_data.src();
4606 const quota = @intCast(u32, try sema.resolveInt(block, src, inst_data.operand, Type.u32, "eval branch quota must be comptime known"));4606 const quota = @intCast(u32, try sema.resolveInt(block, src, inst_data.operand, Type.u32, "eval branch quota must be comptime-known"));
4607 sema.branch_quota = @maximum(sema.branch_quota, quota);4607 sema.branch_quota = @maximum(sema.branch_quota, quota);
4608}4608}
46094609
...@@ -4756,7 +4756,7 @@ fn zirCompileError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -4756,7 +4756,7 @@ fn zirCompileError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
4756 const inst_data = sema.code.instructions.items(.data)[inst].un_node;4756 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
4757 const src = inst_data.src();4757 const src = inst_data.src();
4758 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };4758 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
4759 const msg = try sema.resolveConstString(block, operand_src, inst_data.operand, "compile error string must be comptime known");4759 const msg = try sema.resolveConstString(block, operand_src, inst_data.operand, "compile error string must be comptime-known");
4760 return sema.fail(block, src, "{s}", .{msg});4760 return sema.fail(block, src, "{s}", .{msg});
4761}4761}
47624762
...@@ -5096,7 +5096,7 @@ fn analyzeBlockBody(...@@ -5096,7 +5096,7 @@ fn analyzeBlockBody(
5096 const valid_rt = try sema.validateRunTimeType(child_block, type_src, resolved_ty, false);5096 const valid_rt = try sema.validateRunTimeType(child_block, type_src, resolved_ty, false);
5097 if (!valid_rt) {5097 if (!valid_rt) {
5098 const msg = msg: {5098 const msg = msg: {
5099 const msg = try sema.errMsg(child_block, type_src, "value with comptime only type '{}' depends on runtime control flow", .{resolved_ty.fmt(mod)});5099 const msg = try sema.errMsg(child_block, type_src, "value with comptime-only type '{}' depends on runtime control flow", .{resolved_ty.fmt(mod)});
5100 errdefer msg.destroy(sema.gpa);5100 errdefer msg.destroy(sema.gpa);
51015101
5102 const runtime_src = child_block.runtime_cond orelse child_block.runtime_loop.?;5102 const runtime_src = child_block.runtime_cond orelse child_block.runtime_loop.?;
...@@ -5206,7 +5206,7 @@ fn zirExportValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -5206,7 +5206,7 @@ fn zirExportValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
5206 const src = inst_data.src();5206 const src = inst_data.src();
5207 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };5207 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
5208 const options_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };5208 const options_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
5209 const operand = try sema.resolveInstConst(block, operand_src, extra.operand, "export target must be comptime known");5209 const operand = try sema.resolveInstConst(block, operand_src, extra.operand, "export target must be comptime-known");
5210 const options = sema.resolveExportOptions(block, .unneeded, extra.options) catch |err| switch (err) {5210 const options = sema.resolveExportOptions(block, .unneeded, extra.options) catch |err| switch (err) {
5211 error.NeededSourceLocation => {5211 error.NeededSourceLocation => {
5212 _ = try sema.resolveExportOptions(block, options_src, extra.options);5212 _ = try sema.resolveExportOptions(block, options_src, extra.options);
...@@ -5347,7 +5347,7 @@ fn zirSetAlignStack(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst...@@ -5347,7 +5347,7 @@ fn zirSetAlignStack(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
5347fn zirSetCold(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {5347fn zirSetCold(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
5348 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5348 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5349 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };5349 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
5350 const is_cold = try sema.resolveConstBool(block, operand_src, inst_data.operand, "operand to @setCold must be comptime known");5350 const is_cold = try sema.resolveConstBool(block, operand_src, inst_data.operand, "operand to @setCold must be comptime-known");
5351 const func = sema.func orelse return; // does nothing outside a function5351 const func = sema.func orelse return; // does nothing outside a function
5352 func.is_cold = is_cold;5352 func.is_cold = is_cold;
5353}5353}
...@@ -5355,13 +5355,13 @@ fn zirSetCold(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi...@@ -5355,13 +5355,13 @@ fn zirSetCold(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi
5355fn zirSetFloatMode(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {5355fn zirSetFloatMode(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
5356 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;5356 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
5357 const src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };5357 const src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };
5358 block.float_mode = try sema.resolveBuiltinEnum(block, src, extra.operand, "FloatMode", "operand to @setFloatMode must be comptime known");5358 block.float_mode = try sema.resolveBuiltinEnum(block, src, extra.operand, "FloatMode", "operand to @setFloatMode must be comptime-known");
5359}5359}
53605360
5361fn zirSetRuntimeSafety(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {5361fn zirSetRuntimeSafety(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
5362 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5362 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5363 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };5363 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
5364 block.want_safety = try sema.resolveConstBool(block, operand_src, inst_data.operand, "operand to @setRuntimeSafety must be comptime known");5364 block.want_safety = try sema.resolveConstBool(block, operand_src, inst_data.operand, "operand to @setRuntimeSafety must be comptime-known");
5365}5365}
53665366
5367fn zirFence(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {5367fn zirFence(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
...@@ -5369,7 +5369,7 @@ fn zirFence(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) Co...@@ -5369,7 +5369,7 @@ fn zirFence(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) Co
53695369
5370 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;5370 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
5371 const order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };5371 const order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };
5372 const order = try sema.resolveAtomicOrder(block, order_src, extra.operand, "atomic order of @fence must be comptime known");5372 const order = try sema.resolveAtomicOrder(block, order_src, extra.operand, "atomic order of @fence must be comptime-known");
53735373
5374 if (@enumToInt(order) < @enumToInt(std.builtin.AtomicOrder.Acquire)) {5374 if (@enumToInt(order) < @enumToInt(std.builtin.AtomicOrder.Acquire)) {
5375 return sema.fail(block, order_src, "atomic ordering must be Acquire or stricter", .{});5375 return sema.fail(block, order_src, "atomic ordering must be Acquire or stricter", .{});
...@@ -5861,12 +5861,12 @@ fn addComptimeReturnTypeNote(...@@ -5861,12 +5861,12 @@ fn addComptimeReturnTypeNote(
5861 break :blk func_src.toSrcLoc(src_decl);5861 break :blk func_src.toSrcLoc(src_decl);
5862 };5862 };
5863 if (return_ty.tag() == .generic_poison) {5863 if (return_ty.tag() == .generic_poison) {
5864 return sema.mod.errNoteNonLazy(src_loc, parent, "generic function is instantiated with a comptime only return type", .{});5864 return sema.mod.errNoteNonLazy(src_loc, parent, "generic function is instantiated with a comptime-only return type", .{});
5865 }5865 }
5866 try sema.mod.errNoteNonLazy(5866 try sema.mod.errNoteNonLazy(
5867 src_loc,5867 src_loc,
5868 parent,5868 parent,
5869 "function is being called at comptime because it returns a comptime only type '{}'",5869 "function is being called at comptime because it returns a comptime-only type '{}'",
5870 .{return_ty.fmt(sema.mod)},5870 .{return_ty.fmt(sema.mod)},
5871 );5871 );
5872 try sema.explainWhyTypeIsComptime(block, func_src, parent, src_loc, return_ty);5872 try sema.explainWhyTypeIsComptime(block, func_src, parent, src_loc, return_ty);
...@@ -6006,7 +6006,7 @@ fn analyzeCall(...@@ -6006,7 +6006,7 @@ fn analyzeCall(
6006 }6006 }
60076007
6008 const result: Air.Inst.Ref = if (is_inline_call) res: {6008 const result: Air.Inst.Ref = if (is_inline_call) res: {
6009 const func_val = sema.resolveConstValue(block, func_src, func, "function being called at comptime must be comptime known") catch |err| {6009 const func_val = sema.resolveConstValue(block, func_src, func, "function being called at comptime must be comptime-known") catch |err| {
6010 if (err == error.AnalysisFail and sema.err != null) {6010 if (err == error.AnalysisFail and sema.err != null) {
6011 try sema.addComptimeReturnTypeNote(block, func, func_src, func_ty_info.return_type, sema.err.?, comptime_only_ret_ty);6011 try sema.addComptimeReturnTypeNote(block, func, func_src, func_ty_info.return_type, sema.err.?, comptime_only_ret_ty);
6012 }6012 }
...@@ -6404,7 +6404,7 @@ fn analyzeInlineCallArg(...@@ -6404,7 +6404,7 @@ fn analyzeInlineCallArg(
6404 new_fn_info.param_types[arg_i.*] = param_ty;6404 new_fn_info.param_types[arg_i.*] = param_ty;
6405 const uncasted_arg = uncasted_args[arg_i.*];6405 const uncasted_arg = uncasted_args[arg_i.*];
6406 if (try sema.typeRequiresComptime(param_ty)) {6406 if (try sema.typeRequiresComptime(param_ty)) {
6407 _ = sema.resolveConstMaybeUndefVal(arg_block, arg_src, uncasted_arg, "argument to parameter with comptime only type must be comptime known") catch |err| {6407 _ = sema.resolveConstMaybeUndefVal(arg_block, arg_src, uncasted_arg, "argument to parameter with comptime-only type must be comptime-known") catch |err| {
6408 if (err == error.AnalysisFail and sema.err != null) {6408 if (err == error.AnalysisFail and sema.err != null) {
6409 try sema.addComptimeReturnTypeNote(arg_block, func, func_src, ret_ty, sema.err.?, comptime_only_ret_ty);6409 try sema.addComptimeReturnTypeNote(arg_block, func, func_src, ret_ty, sema.err.?, comptime_only_ret_ty);
6410 }6410 }
...@@ -6415,7 +6415,7 @@ fn analyzeInlineCallArg(...@@ -6415,7 +6415,7 @@ fn analyzeInlineCallArg(
6415 try sema.inst_map.putNoClobber(sema.gpa, inst, casted_arg);6415 try sema.inst_map.putNoClobber(sema.gpa, inst, casted_arg);
64166416
6417 if (is_comptime_call) {6417 if (is_comptime_call) {
6418 const arg_val = sema.resolveConstMaybeUndefVal(arg_block, arg_src, casted_arg, "argument to function being called at comptime must be comptime known") catch |err| {6418 const arg_val = sema.resolveConstMaybeUndefVal(arg_block, arg_src, casted_arg, "argument to function being called at comptime must be comptime-known") catch |err| {
6419 if (err == error.AnalysisFail and sema.err != null) {6419 if (err == error.AnalysisFail and sema.err != null) {
6420 try sema.addComptimeReturnTypeNote(arg_block, func, func_src, ret_ty, sema.err.?, comptime_only_ret_ty);6420 try sema.addComptimeReturnTypeNote(arg_block, func, func_src, ret_ty, sema.err.?, comptime_only_ret_ty);
6421 }6421 }
...@@ -6450,7 +6450,7 @@ fn analyzeInlineCallArg(...@@ -6450,7 +6450,7 @@ fn analyzeInlineCallArg(
6450 try sema.inst_map.putNoClobber(sema.gpa, inst, uncasted_arg);6450 try sema.inst_map.putNoClobber(sema.gpa, inst, uncasted_arg);
64516451
6452 if (is_comptime_call) {6452 if (is_comptime_call) {
6453 const arg_val = sema.resolveConstMaybeUndefVal(arg_block, arg_src, uncasted_arg, "argument to function being called at comptime must be comptime known") catch |err| {6453 const arg_val = sema.resolveConstMaybeUndefVal(arg_block, arg_src, uncasted_arg, "argument to function being called at comptime must be comptime-known") catch |err| {
6454 if (err == error.AnalysisFail and sema.err != null) {6454 if (err == error.AnalysisFail and sema.err != null) {
6455 try sema.addComptimeReturnTypeNote(arg_block, func, func_src, ret_ty, sema.err.?, comptime_only_ret_ty);6455 try sema.addComptimeReturnTypeNote(arg_block, func, func_src, ret_ty, sema.err.?, comptime_only_ret_ty);
6456 }6456 }
...@@ -6536,7 +6536,7 @@ fn instantiateGenericCall(...@@ -6536,7 +6536,7 @@ fn instantiateGenericCall(
6536 const mod = sema.mod;6536 const mod = sema.mod;
6537 const gpa = sema.gpa;6537 const gpa = sema.gpa;
65386538
6539 const func_val = try sema.resolveConstValue(block, func_src, func, "generic function being called must be comptime known");6539 const func_val = try sema.resolveConstValue(block, func_src, func, "generic function being called must be comptime-known");
6540 const module_fn = switch (func_val.tag()) {6540 const module_fn = switch (func_val.tag()) {
6541 .function => func_val.castTag(.function).?.data,6541 .function => func_val.castTag(.function).?.data,
6542 .decl_ref => mod.declPtr(func_val.castTag(.decl_ref).?.data).val.castTag(.function).?.data,6542 .decl_ref => mod.declPtr(func_val.castTag(.decl_ref).?.data).val.castTag(.function).?.data,
...@@ -7030,7 +7030,7 @@ fn zirVectorType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -7030,7 +7030,7 @@ fn zirVectorType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
7030 const elem_type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };7030 const elem_type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
7031 const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };7031 const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
7032 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;7032 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
7033 const len = try sema.resolveInt(block, len_src, extra.lhs, Type.u32, "vector length must be comptime known");7033 const len = try sema.resolveInt(block, len_src, extra.lhs, Type.u32, "vector length must be comptime-known");
7034 const elem_type = try sema.resolveType(block, elem_type_src, extra.rhs);7034 const elem_type = try sema.resolveType(block, elem_type_src, extra.rhs);
7035 try sema.checkVectorElemType(block, elem_type_src, elem_type);7035 try sema.checkVectorElemType(block, elem_type_src, elem_type);
7036 const vector_type = try Type.Tag.vector.create(sema.arena, .{7036 const vector_type = try Type.Tag.vector.create(sema.arena, .{
...@@ -7048,7 +7048,7 @@ fn zirArrayType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -7048,7 +7048,7 @@ fn zirArrayType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
7048 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;7048 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
7049 const len_src: LazySrcLoc = .{ .node_offset_array_type_len = inst_data.src_node };7049 const len_src: LazySrcLoc = .{ .node_offset_array_type_len = inst_data.src_node };
7050 const elem_src: LazySrcLoc = .{ .node_offset_array_type_elem = inst_data.src_node };7050 const elem_src: LazySrcLoc = .{ .node_offset_array_type_elem = inst_data.src_node };
7051 const len = try sema.resolveInt(block, len_src, extra.lhs, Type.usize, "array length must be comptime known");7051 const len = try sema.resolveInt(block, len_src, extra.lhs, Type.usize, "array length must be comptime-known");
7052 const elem_type = try sema.resolveType(block, elem_src, extra.rhs);7052 const elem_type = try sema.resolveType(block, elem_src, extra.rhs);
7053 const array_ty = try Type.array(sema.arena, len, null, elem_type, sema.mod);7053 const array_ty = try Type.array(sema.arena, len, null, elem_type, sema.mod);
70547054
...@@ -7064,11 +7064,11 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil...@@ -7064,11 +7064,11 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil
7064 const len_src: LazySrcLoc = .{ .node_offset_array_type_len = inst_data.src_node };7064 const len_src: LazySrcLoc = .{ .node_offset_array_type_len = inst_data.src_node };
7065 const sentinel_src: LazySrcLoc = .{ .node_offset_array_type_sentinel = inst_data.src_node };7065 const sentinel_src: LazySrcLoc = .{ .node_offset_array_type_sentinel = inst_data.src_node };
7066 const elem_src: LazySrcLoc = .{ .node_offset_array_type_elem = inst_data.src_node };7066 const elem_src: LazySrcLoc = .{ .node_offset_array_type_elem = inst_data.src_node };
7067 const len = try sema.resolveInt(block, len_src, extra.len, Type.usize, "array length must be comptime known");7067 const len = try sema.resolveInt(block, len_src, extra.len, Type.usize, "array length must be comptime-known");
7068 const elem_type = try sema.resolveType(block, elem_src, extra.elem_type);7068 const elem_type = try sema.resolveType(block, elem_src, extra.elem_type);
7069 const uncasted_sentinel = try sema.resolveInst(extra.sentinel);7069 const uncasted_sentinel = try sema.resolveInst(extra.sentinel);
7070 const sentinel = try sema.coerce(block, elem_type, uncasted_sentinel, sentinel_src);7070 const sentinel = try sema.coerce(block, elem_type, uncasted_sentinel, sentinel_src);
7071 const sentinel_val = try sema.resolveConstValue(block, sentinel_src, sentinel, "array sentinel value must be comptime known");7071 const sentinel_val = try sema.resolveConstValue(block, sentinel_src, sentinel, "array sentinel value must be comptime-known");
7072 const array_ty = try Type.array(sema.arena, len, sentinel_val, elem_type, sema.mod);7072 const array_ty = try Type.array(sema.arena, len, sentinel_val, elem_type, sema.mod);
70737073
7074 return sema.addType(array_ty);7074 return sema.addType(array_ty);
...@@ -7752,7 +7752,7 @@ fn zirFunc(...@@ -7752,7 +7752,7 @@ fn zirFunc(
7752 const ret_ty_body = sema.code.extra[extra_index..][0..extra.data.ret_body_len];7752 const ret_ty_body = sema.code.extra[extra_index..][0..extra.data.ret_body_len];
7753 extra_index += ret_ty_body.len;7753 extra_index += ret_ty_body.len;
77547754
7755 const ret_ty_val = try sema.resolveGenericBody(block, ret_ty_src, ret_ty_body, inst, Type.type, "return type must be comptime known");7755 const ret_ty_val = try sema.resolveGenericBody(block, ret_ty_src, ret_ty_body, inst, Type.type, "return type must be comptime-known");
7756 var buffer: Value.ToTypeBuffer = undefined;7756 var buffer: Value.ToTypeBuffer = undefined;
7757 break :blk try ret_ty_val.toType(&buffer).copy(sema.arena);7757 break :blk try ret_ty_val.toType(&buffer).copy(sema.arena);
7758 },7758 },
...@@ -8075,7 +8075,7 @@ fn funcCommon(...@@ -8075,7 +8075,7 @@ fn funcCommon(
8075 return sema.failWithOwnedErrorMsg(msg);8075 return sema.failWithOwnedErrorMsg(msg);
8076 }8076 }
80778077
8078 // If the return type is comptime only but not dependent on parameters then all parameter types also need to be comptime8078 // If the return type is comptime-only but not dependent on parameters then all parameter types also need to be comptime
8079 if (!sema.is_generic_instantiation and has_body and ret_ty_requires_comptime) comptime_check: {8079 if (!sema.is_generic_instantiation and has_body and ret_ty_requires_comptime) comptime_check: {
8080 for (block.params.items) |param| {8080 for (block.params.items) |param| {
8081 if (!param.is_comptime) break;8081 if (!param.is_comptime) break;
...@@ -8084,7 +8084,7 @@ fn funcCommon(...@@ -8084,7 +8084,7 @@ fn funcCommon(
8084 const msg = try sema.errMsg(8084 const msg = try sema.errMsg(
8085 block,8085 block,
8086 ret_ty_src,8086 ret_ty_src,
8087 "function with comptime only return type '{}' requires all parameters to be comptime",8087 "function with comptime-only return type '{}' requires all parameters to be comptime",
8088 .{return_type.fmt(sema.mod)},8088 .{return_type.fmt(sema.mod)},
8089 );8089 );
8090 try sema.explainWhyTypeIsComptime(block, ret_ty_src, msg, ret_ty_src.toSrcLoc(sema.owner_decl), return_type);8090 try sema.explainWhyTypeIsComptime(block, ret_ty_src, msg, ret_ty_src.toSrcLoc(sema.owner_decl), return_type);
...@@ -8586,7 +8586,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -8586,7 +8586,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
8586 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };8586 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
8587 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;8587 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;
8588 const object = try sema.resolveInst(extra.lhs);8588 const object = try sema.resolveInst(extra.lhs);
8589 const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name, "field name must be comptime known");8589 const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name, "field name must be comptime-known");
8590 return sema.fieldVal(block, src, object, field_name, field_name_src);8590 return sema.fieldVal(block, src, object, field_name, field_name_src);
8591}8591}
85928592
...@@ -8599,7 +8599,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -8599,7 +8599,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
8599 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };8599 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
8600 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;8600 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;
8601 const object_ptr = try sema.resolveInst(extra.lhs);8601 const object_ptr = try sema.resolveInst(extra.lhs);
8602 const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name, "field name must be comptime known");8602 const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name, "field name must be comptime-known");
8603 return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src, false);8603 return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src, false);
8604}8604}
86058605
...@@ -8611,7 +8611,7 @@ fn zirFieldCallBindNamed(sema: *Sema, block: *Block, extended: Zir.Inst.Extended...@@ -8611,7 +8611,7 @@ fn zirFieldCallBindNamed(sema: *Sema, block: *Block, extended: Zir.Inst.Extended
8611 const src = LazySrcLoc.nodeOffset(extra.node);8611 const src = LazySrcLoc.nodeOffset(extra.node);
8612 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node };8612 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node };
8613 const object_ptr = try sema.resolveInst(extra.lhs);8613 const object_ptr = try sema.resolveInst(extra.lhs);
8614 const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name, "field name must be comptime known");8614 const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name, "field name must be comptime-known");
8615 return sema.fieldCallBind(block, src, object_ptr, field_name, field_name_src);8615 return sema.fieldCallBind(block, src, object_ptr, field_name, field_name_src);
8616}8616}
86178617
...@@ -10647,7 +10647,7 @@ fn resolveSwitchItemVal(...@@ -10647,7 +10647,7 @@ fn resolveSwitchItemVal(
10647 const src = switch_prong_src.resolve(sema.gpa, sema.mod.declPtr(block.src_decl), switch_node_offset, range_expand);10647 const src = switch_prong_src.resolve(sema.gpa, sema.mod.declPtr(block.src_decl), switch_node_offset, range_expand);
10648 return TypedValue{10648 return TypedValue{
10649 .ty = item_ty,10649 .ty = item_ty,
10650 .val = try sema.resolveConstValue(block, src, item, "switch prong values must be comptime known"),10650 .val = try sema.resolveConstValue(block, src, item, "switch prong values must be comptime-known"),
10651 };10651 };
10652 },10652 },
10653 else => |e| return e,10653 else => |e| return e,
...@@ -10936,7 +10936,7 @@ fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -10936,7 +10936,7 @@ fn zirHasField(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
10936 const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };10936 const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
10937 const name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };10937 const name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
10938 const unresolved_ty = try sema.resolveType(block, ty_src, extra.lhs);10938 const unresolved_ty = try sema.resolveType(block, ty_src, extra.lhs);
10939 const field_name = try sema.resolveConstString(block, name_src, extra.rhs, "field name must be comptime known");10939 const field_name = try sema.resolveConstString(block, name_src, extra.rhs, "field name must be comptime-known");
10940 const ty = try sema.resolveTypeFields(block, ty_src, unresolved_ty);10940 const ty = try sema.resolveTypeFields(block, ty_src, unresolved_ty);
1094110941
10942 const has_field = hf: {10942 const has_field = hf: {
...@@ -10978,7 +10978,7 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -10978,7 +10978,7 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
10978 const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };10978 const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
10979 const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };10979 const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
10980 const container_type = try sema.resolveType(block, lhs_src, extra.lhs);10980 const container_type = try sema.resolveType(block, lhs_src, extra.lhs);
10981 const decl_name = try sema.resolveConstString(block, rhs_src, extra.rhs, "decl name must be comptime known");10981 const decl_name = try sema.resolveConstString(block, rhs_src, extra.rhs, "decl name must be comptime-known");
1098210982
10983 try checkNamespaceType(sema, block, lhs_src, container_type);10983 try checkNamespaceType(sema, block, lhs_src, container_type);
1098410984
...@@ -11042,7 +11042,7 @@ fn zirEmbedFile(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -11042,7 +11042,7 @@ fn zirEmbedFile(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
11042 const mod = sema.mod;11042 const mod = sema.mod;
11043 const inst_data = sema.code.instructions.items(.data)[inst].un_node;11043 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
11044 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };11044 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
11045 const name = try sema.resolveConstString(block, operand_src, inst_data.operand, "file path name must be comptime known");11045 const name = try sema.resolveConstString(block, operand_src, inst_data.operand, "file path name must be comptime-known");
1104611046
11047 const embed_file = mod.embedFile(block.getFileScope(), name) catch |err| switch (err) {11047 const embed_file = mod.embedFile(block.getFileScope(), name) catch |err| switch (err) {
11048 error.ImportOutsidePkgPath => {11048 error.ImportOutsidePkgPath => {
...@@ -11157,7 +11157,7 @@ fn zirShl(...@@ -11157,7 +11157,7 @@ fn zirShl(
11157 if (lhs_val.isUndef()) return sema.addConstUndef(lhs_ty);11157 if (lhs_val.isUndef()) return sema.addConstUndef(lhs_ty);
11158 const rhs_val = maybe_rhs_val orelse {11158 const rhs_val = maybe_rhs_val orelse {
11159 if (scalar_ty.zigTypeTag() == .ComptimeInt) {11159 if (scalar_ty.zigTypeTag() == .ComptimeInt) {
11160 return sema.fail(block, src, "LHS of shift must be a fixed-width integer type, or RHS must be a comptime known", .{});11160 return sema.fail(block, src, "LHS of shift must be a fixed-width integer type, or RHS must be comptime-known", .{});
11161 }11161 }
11162 break :rs rhs_src;11162 break :rs rhs_src;
11163 };11163 };
...@@ -11339,7 +11339,7 @@ fn zirShr(...@@ -11339,7 +11339,7 @@ fn zirShr(
11339 } else rhs_src;11339 } else rhs_src;
1134011340
11341 if (maybe_rhs_val == null and scalar_ty.zigTypeTag() == .ComptimeInt) {11341 if (maybe_rhs_val == null and scalar_ty.zigTypeTag() == .ComptimeInt) {
11342 return sema.fail(block, src, "LHS of shift must be a fixed-width integer type, or RHS must be a comptime known", .{});11342 return sema.fail(block, src, "LHS of shift must be a fixed-width integer type, or RHS must be comptime-known", .{});
11343 }11343 }
1134411344
11345 try sema.requireRuntimeBlock(block, src, runtime_src);11345 try sema.requireRuntimeBlock(block, src, runtime_src);
...@@ -11609,8 +11609,8 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -11609,8 +11609,8 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
11609 const rhs_sent = try sema.addConstant(rhs_info.elem_type, rhs_sent_val);11609 const rhs_sent = try sema.addConstant(rhs_info.elem_type, rhs_sent_val);
11610 const lhs_sent_casted = try sema.coerce(block, resolved_elem_ty, lhs_sent, lhs_src);11610 const lhs_sent_casted = try sema.coerce(block, resolved_elem_ty, lhs_sent, lhs_src);
11611 const rhs_sent_casted = try sema.coerce(block, resolved_elem_ty, rhs_sent, rhs_src);11611 const rhs_sent_casted = try sema.coerce(block, resolved_elem_ty, rhs_sent, rhs_src);
11612 const lhs_sent_casted_val = try sema.resolveConstValue(block, lhs_src, lhs_sent_casted, "array sentinel value must be comptime known");11612 const lhs_sent_casted_val = try sema.resolveConstValue(block, lhs_src, lhs_sent_casted, "array sentinel value must be comptime-known");
11613 const rhs_sent_casted_val = try sema.resolveConstValue(block, rhs_src, rhs_sent_casted, "array sentinel value must be comptime known");11613 const rhs_sent_casted_val = try sema.resolveConstValue(block, rhs_src, rhs_sent_casted, "array sentinel value must be comptime-known");
11614 if (try sema.valuesEqual(block, src, lhs_sent_casted_val, rhs_sent_casted_val, resolved_elem_ty)) {11614 if (try sema.valuesEqual(block, src, lhs_sent_casted_val, rhs_sent_casted_val, resolved_elem_ty)) {
11615 break :s lhs_sent_casted_val;11615 break :s lhs_sent_casted_val;
11616 } else {11616 } else {
...@@ -11618,14 +11618,14 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -11618,14 +11618,14 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
11618 }11618 }
11619 } else {11619 } else {
11620 const lhs_sent_casted = try sema.coerce(block, resolved_elem_ty, lhs_sent, lhs_src);11620 const lhs_sent_casted = try sema.coerce(block, resolved_elem_ty, lhs_sent, lhs_src);
11621 const lhs_sent_casted_val = try sema.resolveConstValue(block, lhs_src, lhs_sent_casted, "array sentinel value must be comptime known");11621 const lhs_sent_casted_val = try sema.resolveConstValue(block, lhs_src, lhs_sent_casted, "array sentinel value must be comptime-known");
11622 break :s lhs_sent_casted_val;11622 break :s lhs_sent_casted_val;
11623 }11623 }
11624 } else {11624 } else {
11625 if (rhs_info.sentinel) |rhs_sent_val| {11625 if (rhs_info.sentinel) |rhs_sent_val| {
11626 const rhs_sent = try sema.addConstant(rhs_info.elem_type, rhs_sent_val);11626 const rhs_sent = try sema.addConstant(rhs_info.elem_type, rhs_sent_val);
11627 const rhs_sent_casted = try sema.coerce(block, resolved_elem_ty, rhs_sent, rhs_src);11627 const rhs_sent_casted = try sema.coerce(block, resolved_elem_ty, rhs_sent, rhs_src);
11628 const rhs_sent_casted_val = try sema.resolveConstValue(block, rhs_src, rhs_sent_casted, "array sentinel value must be comptime known");11628 const rhs_sent_casted_val = try sema.resolveConstValue(block, rhs_src, rhs_sent_casted, "array sentinel value must be comptime-known");
11629 break :s rhs_sent_casted_val;11629 break :s rhs_sent_casted_val;
11630 } else {11630 } else {
11631 break :s null;11631 break :s null;
...@@ -11746,7 +11746,7 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins...@@ -11746,7 +11746,7 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins
11746 // has a sentinel, and this code should compute the length based11746 // has a sentinel, and this code should compute the length based
11747 // on the sentinel value.11747 // on the sentinel value.
11748 .Slice, .Many => {11748 .Slice, .Many => {
11749 const val = try sema.resolveConstValue(block, src, operand, "slice value being concatenated must be comptime known");11749 const val = try sema.resolveConstValue(block, src, operand, "slice value being concatenated must be comptime-known");
11750 return Type.ArrayInfo{11750 return Type.ArrayInfo{
11751 .elem_type = ptr_info.pointee_type,11751 .elem_type = ptr_info.pointee_type,
11752 .sentinel = ptr_info.sentinel,11752 .sentinel = ptr_info.sentinel,
...@@ -11847,7 +11847,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -11847,7 +11847,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
11847 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };11847 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
1184811848
11849 // In `**` rhs must be comptime-known, but lhs can be runtime-known11849 // In `**` rhs must be comptime-known, but lhs can be runtime-known
11850 const factor = try sema.resolveInt(block, rhs_src, extra.rhs, Type.usize, "array multiplication factor must be comptime known");11850 const factor = try sema.resolveInt(block, rhs_src, extra.rhs, Type.usize, "array multiplication factor must be comptime-known");
1185111851
11852 if (lhs_ty.isTuple()) {11852 if (lhs_ty.isTuple()) {
11853 return sema.analyzeTupleMul(block, inst_data.src_node, lhs, factor);11853 return sema.analyzeTupleMul(block, inst_data.src_node, lhs, factor);
...@@ -16223,14 +16223,14 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -16223,14 +16223,14 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
16223 const sentinel = if (inst_data.flags.has_sentinel) blk: {16223 const sentinel = if (inst_data.flags.has_sentinel) blk: {
16224 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);16224 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
16225 extra_i += 1;16225 extra_i += 1;
16226 break :blk (try sema.resolveInstConst(block, sentinel_src, ref, "pointer sentinel value must be comptime known")).val;16226 break :blk (try sema.resolveInstConst(block, sentinel_src, ref, "pointer sentinel value must be comptime-known")).val;
16227 } else null;16227 } else null;
1622816228
16229 const abi_align: u32 = if (inst_data.flags.has_align) blk: {16229 const abi_align: u32 = if (inst_data.flags.has_align) blk: {
16230 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);16230 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
16231 extra_i += 1;16231 extra_i += 1;
16232 const coerced = try sema.coerce(block, Type.u32, try sema.resolveInst(ref), align_src);16232 const coerced = try sema.coerce(block, Type.u32, try sema.resolveInst(ref), align_src);
16233 const val = try sema.resolveConstValue(block, align_src, coerced, "pointer alignment must be comptime known");16233 const val = try sema.resolveConstValue(block, align_src, coerced, "pointer alignment must be comptime-known");
16234 // Check if this happens to be the lazy alignment of our element type, in16234 // Check if this happens to be the lazy alignment of our element type, in
16235 // which case we can make this 0 without resolving it.16235 // which case we can make this 0 without resolving it.
16236 if (val.castTag(.lazy_align)) |payload| {16236 if (val.castTag(.lazy_align)) |payload| {
...@@ -16252,14 +16252,14 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -16252,14 +16252,14 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
16252 const bit_offset = if (inst_data.flags.has_bit_range) blk: {16252 const bit_offset = if (inst_data.flags.has_bit_range) blk: {
16253 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);16253 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
16254 extra_i += 1;16254 extra_i += 1;
16255 const bit_offset = try sema.resolveInt(block, bitoffset_src, ref, Type.u16, "pointer bit-offset must be comptime known");16255 const bit_offset = try sema.resolveInt(block, bitoffset_src, ref, Type.u16, "pointer bit-offset must be comptime-known");
16256 break :blk @intCast(u16, bit_offset);16256 break :blk @intCast(u16, bit_offset);
16257 } else 0;16257 } else 0;
1625816258
16259 const host_size: u16 = if (inst_data.flags.has_bit_range) blk: {16259 const host_size: u16 = if (inst_data.flags.has_bit_range) blk: {
16260 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);16260 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
16261 extra_i += 1;16261 extra_i += 1;
16262 const host_size = try sema.resolveInt(block, hostsize_src, ref, Type.u16, "pointer host size must be comptime known");16262 const host_size = try sema.resolveInt(block, hostsize_src, ref, Type.u16, "pointer host size must be comptime-known");
16263 break :blk @intCast(u16, host_size);16263 break :blk @intCast(u16, host_size);
16264 } else 0;16264 } else 0;
1626516265
...@@ -16383,7 +16383,7 @@ fn zirUnionInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -16383,7 +16383,7 @@ fn zirUnionInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
16383 const init_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };16383 const init_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };
16384 const extra = sema.code.extraData(Zir.Inst.UnionInit, inst_data.payload_index).data;16384 const extra = sema.code.extraData(Zir.Inst.UnionInit, inst_data.payload_index).data;
16385 const union_ty = try sema.resolveType(block, ty_src, extra.union_type);16385 const union_ty = try sema.resolveType(block, ty_src, extra.union_type);
16386 const field_name = try sema.resolveConstString(block, field_src, extra.field_name, "name of field being initialized must be comptime known");16386 const field_name = try sema.resolveConstString(block, field_src, extra.field_name, "name of field being initialized must be comptime-known");
16387 const init = try sema.resolveInst(extra.init);16387 const init = try sema.resolveInst(extra.init);
16388 return sema.unionInit(block, init, init_src, union_ty, ty_src, field_name, field_src);16388 return sema.unionInit(block, init, init_src, union_ty, ty_src, field_name, field_src);
16389}16389}
...@@ -16481,7 +16481,7 @@ fn zirStructInit(...@@ -16481,7 +16481,7 @@ fn zirStructInit(
16481 field_inits[field_index] = try sema.resolveInst(item.data.init);16481 field_inits[field_index] = try sema.resolveInst(item.data.init);
16482 if (!is_packed) if (resolved_ty.structFieldValueComptime(field_index)) |default_value| {16482 if (!is_packed) if (resolved_ty.structFieldValueComptime(field_index)) |default_value| {
16483 const init_val = (try sema.resolveMaybeUndefVal(block, field_src, field_inits[field_index])) orelse {16483 const init_val = (try sema.resolveMaybeUndefVal(block, field_src, field_inits[field_index])) orelse {
16484 return sema.failWithNeededComptime(block, field_src, "value stored in comptime field must be comptime known");16484 return sema.failWithNeededComptime(block, field_src, "value stored in comptime field must be comptime-known");
16485 };16485 };
1648616486
16487 if (!init_val.eql(default_value, resolved_ty.structFieldType(field_index), sema.mod)) {16487 if (!init_val.eql(default_value, resolved_ty.structFieldType(field_index), sema.mod)) {
...@@ -16992,7 +16992,7 @@ fn zirFieldTypeRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -16992,7 +16992,7 @@ fn zirFieldTypeRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
16992 const ty_src = inst_data.src();16992 const ty_src = inst_data.src();
16993 const field_src = inst_data.src();16993 const field_src = inst_data.src();
16994 const aggregate_ty = try sema.resolveType(block, ty_src, extra.container_type);16994 const aggregate_ty = try sema.resolveType(block, ty_src, extra.container_type);
16995 const field_name = try sema.resolveConstString(block, field_src, extra.field_name, "field name must be comptime known");16995 const field_name = try sema.resolveConstString(block, field_src, extra.field_name, "field name must be comptime-known");
16996 return sema.fieldType(block, aggregate_ty, field_name, field_src, ty_src);16996 return sema.fieldType(block, aggregate_ty, field_name, field_src, ty_src);
16997}16997}
1699816998
...@@ -17273,7 +17273,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in...@@ -17273,7 +17273,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in
17273 const uncasted_operand = try sema.resolveInst(extra.operand);17273 const uncasted_operand = try sema.resolveInst(extra.operand);
17274 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };17274 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };
17275 const type_info = try sema.coerce(block, type_info_ty, uncasted_operand, operand_src);17275 const type_info = try sema.coerce(block, type_info_ty, uncasted_operand, operand_src);
17276 const val = try sema.resolveConstValue(block, operand_src, type_info, "operand to @Type must be comptime known");17276 const val = try sema.resolveConstValue(block, operand_src, type_info, "operand to @Type must be comptime-known");
17277 const union_val = val.cast(Value.Payload.Union).?.data;17277 const union_val = val.cast(Value.Payload.Union).?.data;
17278 const target = mod.getTarget();17278 const target = mod.getTarget();
17279 const tag_index = type_info_ty.unionTagFieldIndex(union_val.tag, mod).?;17279 const tag_index = type_info_ty.unionTagFieldIndex(union_val.tag, mod).?;
...@@ -18213,7 +18213,7 @@ fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -18213,7 +18213,7 @@ fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
18213 const result_val = try sema.floatToInt(block, operand_src, val, operand_ty, dest_ty);18213 const result_val = try sema.floatToInt(block, operand_src, val, operand_ty, dest_ty);
18214 return sema.addConstant(dest_ty, result_val);18214 return sema.addConstant(dest_ty, result_val);
18215 } else if (dest_ty.zigTypeTag() == .ComptimeInt) {18215 } else if (dest_ty.zigTypeTag() == .ComptimeInt) {
18216 return sema.failWithNeededComptime(block, operand_src, "value being casted to 'comptime_int' must be comptime known");18216 return sema.failWithNeededComptime(block, operand_src, "value being casted to 'comptime_int' must be comptime-known");
18217 }18217 }
1821818218
18219 try sema.requireRuntimeBlock(block, inst_data.src(), operand_src);18219 try sema.requireRuntimeBlock(block, inst_data.src(), operand_src);
...@@ -18246,7 +18246,7 @@ fn zirIntToFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -18246,7 +18246,7 @@ fn zirIntToFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
18246 const result_val = try val.intToFloatAdvanced(sema.arena, operand_ty, dest_ty, target, sema.kit(block, operand_src));18246 const result_val = try val.intToFloatAdvanced(sema.arena, operand_ty, dest_ty, target, sema.kit(block, operand_src));
18247 return sema.addConstant(dest_ty, result_val);18247 return sema.addConstant(dest_ty, result_val);
18248 } else if (dest_ty.zigTypeTag() == .ComptimeFloat) {18248 } else if (dest_ty.zigTypeTag() == .ComptimeFloat) {
18249 return sema.failWithNeededComptime(block, operand_src, "value being casted to 'comptime_float' must be comptime known");18249 return sema.failWithNeededComptime(block, operand_src, "value being casted to 'comptime_float' must be comptime-known");
18250 }18250 }
1825118251
18252 try sema.requireRuntimeBlock(block, inst_data.src(), operand_src);18252 try sema.requireRuntimeBlock(block, inst_data.src(), operand_src);
...@@ -18826,7 +18826,7 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6...@@ -18826,7 +18826,7 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6
18826 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;18826 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
1882718827
18828 const ty = try sema.resolveType(block, lhs_src, extra.lhs);18828 const ty = try sema.resolveType(block, lhs_src, extra.lhs);
18829 const field_name = try sema.resolveConstString(block, rhs_src, extra.rhs, "name of field must be comptime known");18829 const field_name = try sema.resolveConstString(block, rhs_src, extra.rhs, "name of field must be comptime-known");
18830 const target = sema.mod.getTarget();18830 const target = sema.mod.getTarget();
1883118831
18832 try sema.resolveTypeLayout(block, lhs_src, ty);18832 try sema.resolveTypeLayout(block, lhs_src, ty);
...@@ -19301,19 +19301,19 @@ fn resolveExportOptions(...@@ -19301,19 +19301,19 @@ fn resolveExportOptions(
19301 const visibility_src = sema.maybeOptionsSrc(block, src, "visibility");19301 const visibility_src = sema.maybeOptionsSrc(block, src, "visibility");
1930219302
19303 const name_operand = try sema.fieldVal(block, src, options, "name", name_src);19303 const name_operand = try sema.fieldVal(block, src, options, "name", name_src);
19304 const name_val = try sema.resolveConstValue(block, name_src, name_operand, "name of exported value must be comptime known");19304 const name_val = try sema.resolveConstValue(block, name_src, name_operand, "name of exported value must be comptime-known");
19305 const name_ty = Type.initTag(.const_slice_u8);19305 const name_ty = Type.initTag(.const_slice_u8);
19306 const name = try name_val.toAllocatedBytes(name_ty, sema.arena, sema.mod);19306 const name = try name_val.toAllocatedBytes(name_ty, sema.arena, sema.mod);
1930719307
19308 const linkage_operand = try sema.fieldVal(block, src, options, "linkage", linkage_src);19308 const linkage_operand = try sema.fieldVal(block, src, options, "linkage", linkage_src);
19309 const linkage_val = try sema.resolveConstValue(block, linkage_src, linkage_operand, "linkage of exported value must be comptime known");19309 const linkage_val = try sema.resolveConstValue(block, linkage_src, linkage_operand, "linkage of exported value must be comptime-known");
19310 const linkage = linkage_val.toEnum(std.builtin.GlobalLinkage);19310 const linkage = linkage_val.toEnum(std.builtin.GlobalLinkage);
1931119311
19312 const section = try sema.fieldVal(block, src, options, "section", section_src);19312 const section = try sema.fieldVal(block, src, options, "section", section_src);
19313 const section_val = try sema.resolveConstValue(block, section_src, section, "linksection of exported value must be comptime known");19313 const section_val = try sema.resolveConstValue(block, section_src, section, "linksection of exported value must be comptime-known");
1931419314
19315 const visibility_operand = try sema.fieldVal(block, src, options, "visibility", visibility_src);19315 const visibility_operand = try sema.fieldVal(block, src, options, "visibility", visibility_src);
19316 const visibility_val = try sema.resolveConstValue(block, visibility_src, visibility_operand, "visibility of exported value must be comptime known");19316 const visibility_val = try sema.resolveConstValue(block, visibility_src, visibility_operand, "visibility of exported value must be comptime-known");
19317 const visibility = visibility_val.toEnum(std.builtin.SymbolVisibility);19317 const visibility = visibility_val.toEnum(std.builtin.SymbolVisibility);
1931819318
19319 if (name.len < 1) {19319 if (name.len < 1) {
...@@ -19369,7 +19369,7 @@ fn resolveAtomicRmwOp(...@@ -19369,7 +19369,7 @@ fn resolveAtomicRmwOp(
19369 src: LazySrcLoc,19369 src: LazySrcLoc,
19370 zir_ref: Zir.Inst.Ref,19370 zir_ref: Zir.Inst.Ref,
19371) CompileError!std.builtin.AtomicRmwOp {19371) CompileError!std.builtin.AtomicRmwOp {
19372 return resolveBuiltinEnum(sema, block, src, zir_ref, "AtomicRmwOp", "@atomicRmW operation must be comptime known");19372 return resolveBuiltinEnum(sema, block, src, zir_ref, "AtomicRmwOp", "@atomicRmW operation must be comptime-known");
19373}19373}
1937419374
19375fn zirCmpxchg(19375fn zirCmpxchg(
...@@ -19405,8 +19405,8 @@ fn zirCmpxchg(...@@ -19405,8 +19405,8 @@ fn zirCmpxchg(
19405 const uncasted_ptr = try sema.resolveInst(extra.ptr);19405 const uncasted_ptr = try sema.resolveInst(extra.ptr);
19406 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);19406 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);
19407 const new_value = try sema.coerce(block, elem_ty, try sema.resolveInst(extra.new_value), new_value_src);19407 const new_value = try sema.coerce(block, elem_ty, try sema.resolveInst(extra.new_value), new_value_src);
19408 const success_order = try sema.resolveAtomicOrder(block, success_order_src, extra.success_order, "atomic order of cmpxchg success must be comptime known");19408 const success_order = try sema.resolveAtomicOrder(block, success_order_src, extra.success_order, "atomic order of cmpxchg success must be comptime-known");
19409 const failure_order = try sema.resolveAtomicOrder(block, failure_order_src, extra.failure_order, "atomic order of cmpxchg failure must be comptime known");19409 const failure_order = try sema.resolveAtomicOrder(block, failure_order_src, extra.failure_order, "atomic order of cmpxchg failure must be comptime-known");
1941019410
19411 if (@enumToInt(success_order) < @enumToInt(std.builtin.AtomicOrder.Monotonic)) {19411 if (@enumToInt(success_order) < @enumToInt(std.builtin.AtomicOrder.Monotonic)) {
19412 return sema.fail(block, success_order_src, "success atomic ordering must be Monotonic or stricter", .{});19412 return sema.fail(block, success_order_src, "success atomic ordering must be Monotonic or stricter", .{});
...@@ -19471,7 +19471,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I...@@ -19471,7 +19471,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
19471 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;19471 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
19472 const len_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };19472 const len_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
19473 const scalar_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };19473 const scalar_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
19474 const len = @intCast(u32, try sema.resolveInt(block, len_src, extra.lhs, Type.u32, "vector splat destination length must be comptime known"));19474 const len = @intCast(u32, try sema.resolveInt(block, len_src, extra.lhs, Type.u32, "vector splat destination length must be comptime-known"));
19475 const scalar = try sema.resolveInst(extra.rhs);19475 const scalar = try sema.resolveInst(extra.rhs);
19476 const scalar_ty = sema.typeOf(scalar);19476 const scalar_ty = sema.typeOf(scalar);
19477 try sema.checkVectorElemType(block, scalar_src, scalar_ty);19477 try sema.checkVectorElemType(block, scalar_src, scalar_ty);
...@@ -19497,7 +19497,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -19497,7 +19497,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
19497 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;19497 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
19498 const op_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };19498 const op_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
19499 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };19499 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
19500 const operation = try sema.resolveBuiltinEnum(block, op_src, extra.lhs, "ReduceOp", "@reduce operation must be comptime known");19500 const operation = try sema.resolveBuiltinEnum(block, op_src, extra.lhs, "ReduceOp", "@reduce operation must be comptime-known");
19501 const operand = try sema.resolveInst(extra.rhs);19501 const operand = try sema.resolveInst(extra.rhs);
19502 const operand_ty = sema.typeOf(operand);19502 const operand_ty = sema.typeOf(operand);
19503 const target = sema.mod.getTarget();19503 const target = sema.mod.getTarget();
...@@ -19584,7 +19584,7 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -19584,7 +19584,7 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
19584 .elem_type = Type.@"i32",19584 .elem_type = Type.@"i32",
19585 });19585 });
19586 mask = try sema.coerce(block, mask_ty, mask, mask_src);19586 mask = try sema.coerce(block, mask_ty, mask, mask_src);
19587 const mask_val = try sema.resolveConstMaybeUndefVal(block, mask_src, mask, "shuffle mask must be comptime known");19587 const mask_val = try sema.resolveConstMaybeUndefVal(block, mask_src, mask, "shuffle mask must be comptime-known");
19588 return sema.analyzeShuffle(block, inst_data.src_node, elem_ty, a, b, mask_val, @intCast(u32, mask_len));19588 return sema.analyzeShuffle(block, inst_data.src_node, elem_ty, a, b, mask_val, @intCast(u32, mask_len));
19589}19589}
1959019590
...@@ -19852,7 +19852,7 @@ fn zirAtomicLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -19852,7 +19852,7 @@ fn zirAtomicLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
19852 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);19852 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);
19853 const uncasted_ptr = try sema.resolveInst(extra.ptr);19853 const uncasted_ptr = try sema.resolveInst(extra.ptr);
19854 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, true);19854 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, true);
19855 const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering, "atomic order of @atomicLoad must be comptime known");19855 const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering, "atomic order of @atomicLoad must be comptime-known");
1985619856
19857 switch (order) {19857 switch (order) {
19858 .Release, .AcqRel => {19858 .Release, .AcqRel => {
...@@ -19916,7 +19916,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -19916,7 +19916,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
19916 },19916 },
19917 else => {},19917 else => {},
19918 }19918 }
19919 const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering, "atomic order of @atomicRmW must be comptime known");19919 const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering, "atomic order of @atomicRmW must be comptime-known");
1992019920
19921 if (order == .Unordered) {19921 if (order == .Unordered) {
19922 return sema.fail(block, order_src, "@atomicRmw atomic ordering must not be Unordered", .{});19922 return sema.fail(block, order_src, "@atomicRmw atomic ordering must not be Unordered", .{});
...@@ -19984,7 +19984,7 @@ fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -19984,7 +19984,7 @@ fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
19984 const elem_ty = sema.typeOf(operand);19984 const elem_ty = sema.typeOf(operand);
19985 const uncasted_ptr = try sema.resolveInst(extra.ptr);19985 const uncasted_ptr = try sema.resolveInst(extra.ptr);
19986 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);19986 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);
19987 const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering, "atomic order of @atomicStore must be comptime known");19987 const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering, "atomic order of @atomicStore must be comptime-known");
1998819988
19989 const air_tag: Air.Inst.Tag = switch (order) {19989 const air_tag: Air.Inst.Tag = switch (order) {
19990 .Acquire, .AcqRel => {19990 .Acquire, .AcqRel => {
...@@ -20087,11 +20087,11 @@ fn resolveCallOptions(...@@ -20087,11 +20087,11 @@ fn resolveCallOptions(
20087 const stack_src = sema.maybeOptionsSrc(block, src, "stack");20087 const stack_src = sema.maybeOptionsSrc(block, src, "stack");
2008820088
20089 const modifier = try sema.fieldVal(block, src, options, "modifier", modifier_src);20089 const modifier = try sema.fieldVal(block, src, options, "modifier", modifier_src);
20090 const modifier_val = try sema.resolveConstValue(block, modifier_src, modifier, "call modifier must be comptime known");20090 const modifier_val = try sema.resolveConstValue(block, modifier_src, modifier, "call modifier must be comptime-known");
20091 const wanted_modifier = modifier_val.toEnum(std.builtin.CallOptions.Modifier);20091 const wanted_modifier = modifier_val.toEnum(std.builtin.CallOptions.Modifier);
2009220092
20093 const stack = try sema.fieldVal(block, src, options, "stack", stack_src);20093 const stack = try sema.fieldVal(block, src, options, "stack", stack_src);
20094 const stack_val = try sema.resolveConstValue(block, stack_src, stack, "call stack value must be comptime known");20094 const stack_val = try sema.resolveConstValue(block, stack_src, stack, "call stack value must be comptime-known");
2009520095
20096 if (!stack_val.isNull()) {20096 if (!stack_val.isNull()) {
20097 return sema.fail(block, stack_src, "TODO: implement @call with stack", .{});20097 return sema.fail(block, stack_src, "TODO: implement @call with stack", .{});
...@@ -20221,7 +20221,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr...@@ -20221,7 +20221,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
20221 const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };20221 const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };
2022220222
20223 const struct_ty = try sema.resolveType(block, ty_src, extra.parent_type);20223 const struct_ty = try sema.resolveType(block, ty_src, extra.parent_type);
20224 const field_name = try sema.resolveConstString(block, name_src, extra.field_name, "field name must be comptime known");20224 const field_name = try sema.resolveConstString(block, name_src, extra.field_name, "field name must be comptime-known");
20225 const field_ptr = try sema.resolveInst(extra.field_ptr);20225 const field_ptr = try sema.resolveInst(extra.field_ptr);
20226 const field_ptr_ty = sema.typeOf(field_ptr);20226 const field_ptr_ty = sema.typeOf(field_ptr);
2022720227
...@@ -20538,7 +20538,7 @@ fn zirVarExtended(...@@ -20538,7 +20538,7 @@ fn zirVarExtended(
20538 uncasted_init;20538 uncasted_init;
2053920539
20540 break :blk (try sema.resolveMaybeUndefVal(block, init_src, init)) orelse20540 break :blk (try sema.resolveMaybeUndefVal(block, init_src, init)) orelse
20541 return sema.failWithNeededComptime(block, init_src, "container level variable initializers must be comptime known");20541 return sema.failWithNeededComptime(block, init_src, "container level variable initializers must be comptime-known");
20542 } else Value.initTag(.unreachable_value);20542 } else Value.initTag(.unreachable_value);
2054320543
20544 try sema.validateVarType(block, ty_src, var_ty, small.is_extern);20544 try sema.validateVarType(block, ty_src, var_ty, small.is_extern);
...@@ -20607,7 +20607,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -20607,7 +20607,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
20607 const body = sema.code.extra[extra_index..][0..body_len];20607 const body = sema.code.extra[extra_index..][0..body_len];
20608 extra_index += body.len;20608 extra_index += body.len;
2060920609
20610 const val = try sema.resolveGenericBody(block, align_src, body, inst, Type.u29, "alignment must be comptime known");20610 const val = try sema.resolveGenericBody(block, align_src, body, inst, Type.u29, "alignment must be comptime-known");
20611 if (val.tag() == .generic_poison) {20611 if (val.tag() == .generic_poison) {
20612 break :blk null;20612 break :blk null;
20613 }20613 }
...@@ -20621,7 +20621,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -20621,7 +20621,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
20621 } else if (extra.data.bits.has_align_ref) blk: {20621 } else if (extra.data.bits.has_align_ref) blk: {
20622 const align_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);20622 const align_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
20623 extra_index += 1;20623 extra_index += 1;
20624 const align_tv = sema.resolveInstConst(block, align_src, align_ref, "alignment must be comptime known") catch |err| switch (err) {20624 const align_tv = sema.resolveInstConst(block, align_src, align_ref, "alignment must be comptime-known") catch |err| switch (err) {
20625 error.GenericPoison => {20625 error.GenericPoison => {
20626 break :blk null;20626 break :blk null;
20627 },20627 },
...@@ -20643,7 +20643,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -20643,7 +20643,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
20643 extra_index += body.len;20643 extra_index += body.len;
2064420644
20645 const addrspace_ty = try sema.getBuiltinType(block, addrspace_src, "AddressSpace");20645 const addrspace_ty = try sema.getBuiltinType(block, addrspace_src, "AddressSpace");
20646 const val = try sema.resolveGenericBody(block, addrspace_src, body, inst, addrspace_ty, "addrespace must be comptime known");20646 const val = try sema.resolveGenericBody(block, addrspace_src, body, inst, addrspace_ty, "addrespace must be comptime-known");
20647 if (val.tag() == .generic_poison) {20647 if (val.tag() == .generic_poison) {
20648 break :blk null;20648 break :blk null;
20649 }20649 }
...@@ -20651,7 +20651,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -20651,7 +20651,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
20651 } else if (extra.data.bits.has_addrspace_ref) blk: {20651 } else if (extra.data.bits.has_addrspace_ref) blk: {
20652 const addrspace_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);20652 const addrspace_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
20653 extra_index += 1;20653 extra_index += 1;
20654 const addrspace_tv = sema.resolveInstConst(block, addrspace_src, addrspace_ref, "addrespace must be comptime known") catch |err| switch (err) {20654 const addrspace_tv = sema.resolveInstConst(block, addrspace_src, addrspace_ref, "addrespace must be comptime-known") catch |err| switch (err) {
20655 error.GenericPoison => {20655 error.GenericPoison => {
20656 break :blk null;20656 break :blk null;
20657 },20657 },
...@@ -20666,7 +20666,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -20666,7 +20666,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
20666 const body = sema.code.extra[extra_index..][0..body_len];20666 const body = sema.code.extra[extra_index..][0..body_len];
20667 extra_index += body.len;20667 extra_index += body.len;
2066820668
20669 const val = try sema.resolveGenericBody(block, section_src, body, inst, Type.initTag(.const_slice_u8), "linksection must be comptime known");20669 const val = try sema.resolveGenericBody(block, section_src, body, inst, Type.initTag(.const_slice_u8), "linksection must be comptime-known");
20670 if (val.tag() == .generic_poison) {20670 if (val.tag() == .generic_poison) {
20671 break :blk FuncLinkSection{ .generic = {} };20671 break :blk FuncLinkSection{ .generic = {} };
20672 }20672 }
...@@ -20674,7 +20674,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -20674,7 +20674,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
20674 } else if (extra.data.bits.has_section_ref) blk: {20674 } else if (extra.data.bits.has_section_ref) blk: {
20675 const section_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);20675 const section_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
20676 extra_index += 1;20676 extra_index += 1;
20677 const section_tv = sema.resolveInstConst(block, section_src, section_ref, "linksection must be comptime known") catch |err| switch (err) {20677 const section_tv = sema.resolveInstConst(block, section_src, section_ref, "linksection must be comptime-known") catch |err| switch (err) {
20678 error.GenericPoison => {20678 error.GenericPoison => {
20679 break :blk FuncLinkSection{ .generic = {} };20679 break :blk FuncLinkSection{ .generic = {} };
20680 },20680 },
...@@ -20691,7 +20691,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -20691,7 +20691,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
20691 extra_index += body.len;20691 extra_index += body.len;
2069220692
20693 const cc_ty = try sema.getBuiltinType(block, addrspace_src, "CallingConvention");20693 const cc_ty = try sema.getBuiltinType(block, addrspace_src, "CallingConvention");
20694 const val = try sema.resolveGenericBody(block, cc_src, body, inst, cc_ty, "calling convention must be comptime known");20694 const val = try sema.resolveGenericBody(block, cc_src, body, inst, cc_ty, "calling convention must be comptime-known");
20695 if (val.tag() == .generic_poison) {20695 if (val.tag() == .generic_poison) {
20696 break :blk null;20696 break :blk null;
20697 }20697 }
...@@ -20699,7 +20699,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -20699,7 +20699,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
20699 } else if (extra.data.bits.has_cc_ref) blk: {20699 } else if (extra.data.bits.has_cc_ref) blk: {
20700 const cc_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);20700 const cc_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
20701 extra_index += 1;20701 extra_index += 1;
20702 const cc_tv = sema.resolveInstConst(block, cc_src, cc_ref, "calling convention must be comptime known") catch |err| switch (err) {20702 const cc_tv = sema.resolveInstConst(block, cc_src, cc_ref, "calling convention must be comptime-known") catch |err| switch (err) {
20703 error.GenericPoison => {20703 error.GenericPoison => {
20704 break :blk null;20704 break :blk null;
20705 },20705 },
...@@ -20714,14 +20714,14 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -20714,14 +20714,14 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
20714 const body = sema.code.extra[extra_index..][0..body_len];20714 const body = sema.code.extra[extra_index..][0..body_len];
20715 extra_index += body.len;20715 extra_index += body.len;
2071620716
20717 const val = try sema.resolveGenericBody(block, ret_src, body, inst, Type.type, "return type must be comptime known");20717 const val = try sema.resolveGenericBody(block, ret_src, body, inst, Type.type, "return type must be comptime-known");
20718 var buffer: Value.ToTypeBuffer = undefined;20718 var buffer: Value.ToTypeBuffer = undefined;
20719 const ty = try val.toType(&buffer).copy(sema.arena);20719 const ty = try val.toType(&buffer).copy(sema.arena);
20720 break :blk ty;20720 break :blk ty;
20721 } else if (extra.data.bits.has_ret_ty_ref) blk: {20721 } else if (extra.data.bits.has_ret_ty_ref) blk: {
20722 const ret_ty_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);20722 const ret_ty_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
20723 extra_index += 1;20723 extra_index += 1;
20724 const ret_ty_tv = sema.resolveInstConst(block, ret_src, ret_ty_ref, "return type must be comptime known") catch |err| switch (err) {20724 const ret_ty_tv = sema.resolveInstConst(block, ret_src, ret_ty_ref, "return type must be comptime-known") catch |err| switch (err) {
20725 error.GenericPoison => {20725 error.GenericPoison => {
20726 break :blk Type.initTag(.generic_poison);20726 break :blk Type.initTag(.generic_poison);
20727 },20727 },
...@@ -20777,7 +20777,7 @@ fn zirCUndef(...@@ -20777,7 +20777,7 @@ fn zirCUndef(
20777 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;20777 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
20778 const src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };20778 const src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };
2077920779
20780 const name = try sema.resolveConstString(block, src, extra.operand, "name of macro being undefined must be comptime known");20780 const name = try sema.resolveConstString(block, src, extra.operand, "name of macro being undefined must be comptime-known");
20781 try block.c_import_buf.?.writer().print("#undefine {s}\n", .{name});20781 try block.c_import_buf.?.writer().print("#undefine {s}\n", .{name});
20782 return Air.Inst.Ref.void_value;20782 return Air.Inst.Ref.void_value;
20783}20783}
...@@ -20790,7 +20790,7 @@ fn zirCInclude(...@@ -20790,7 +20790,7 @@ fn zirCInclude(
20790 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;20790 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
20791 const src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };20791 const src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };
2079220792
20793 const name = try sema.resolveConstString(block, src, extra.operand, "path being included must be comptime known");20793 const name = try sema.resolveConstString(block, src, extra.operand, "path being included must be comptime-known");
20794 try block.c_import_buf.?.writer().print("#include <{s}>\n", .{name});20794 try block.c_import_buf.?.writer().print("#include <{s}>\n", .{name});
20795 return Air.Inst.Ref.void_value;20795 return Air.Inst.Ref.void_value;
20796}20796}
...@@ -20804,10 +20804,10 @@ fn zirCDefine(...@@ -20804,10 +20804,10 @@ fn zirCDefine(
20804 const name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };20804 const name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };
20805 const val_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node };20805 const val_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node };
2080620806
20807 const name = try sema.resolveConstString(block, name_src, extra.lhs, "name of macro being undefined must be comptime known");20807 const name = try sema.resolveConstString(block, name_src, extra.lhs, "name of macro being undefined must be comptime-known");
20808 const rhs = try sema.resolveInst(extra.rhs);20808 const rhs = try sema.resolveInst(extra.rhs);
20809 if (sema.typeOf(rhs).zigTypeTag() != .Void) {20809 if (sema.typeOf(rhs).zigTypeTag() != .Void) {
20810 const value = try sema.resolveConstString(block, val_src, extra.rhs, "value of macro being undefined must be comptime known");20810 const value = try sema.resolveConstString(block, val_src, extra.rhs, "value of macro being undefined must be comptime-known");
20811 try block.c_import_buf.?.writer().print("#define {s} {s}\n", .{ name, value });20811 try block.c_import_buf.?.writer().print("#define {s} {s}\n", .{ name, value });
20812 } else {20812 } else {
20813 try block.c_import_buf.?.writer().print("#define {s}\n", .{name});20813 try block.c_import_buf.?.writer().print("#define {s}\n", .{name});
...@@ -20828,7 +20828,7 @@ fn zirWasmMemorySize(...@@ -20828,7 +20828,7 @@ fn zirWasmMemorySize(
20828 return sema.fail(block, builtin_src, "builtin @wasmMemorySize is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)});20828 return sema.fail(block, builtin_src, "builtin @wasmMemorySize is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)});
20829 }20829 }
2083020830
20831 const index = @intCast(u32, try sema.resolveInt(block, index_src, extra.operand, Type.u32, "wasm memory size index must be comptime known"));20831 const index = @intCast(u32, try sema.resolveInt(block, index_src, extra.operand, Type.u32, "wasm memory size index must be comptime-known"));
20832 try sema.requireRuntimeBlock(block, builtin_src, null);20832 try sema.requireRuntimeBlock(block, builtin_src, null);
20833 return block.addInst(.{20833 return block.addInst(.{
20834 .tag = .wasm_memory_size,20834 .tag = .wasm_memory_size,
...@@ -20853,7 +20853,7 @@ fn zirWasmMemoryGrow(...@@ -20853,7 +20853,7 @@ fn zirWasmMemoryGrow(
20853 return sema.fail(block, builtin_src, "builtin @wasmMemoryGrow is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)});20853 return sema.fail(block, builtin_src, "builtin @wasmMemoryGrow is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)});
20854 }20854 }
2085520855
20856 const index = @intCast(u32, try sema.resolveInt(block, index_src, extra.lhs, Type.u32, "wasm memory size index must be comptime known"));20856 const index = @intCast(u32, try sema.resolveInt(block, index_src, extra.lhs, Type.u32, "wasm memory size index must be comptime-known"));
20857 const delta = try sema.coerce(block, Type.u32, try sema.resolveInst(extra.rhs), delta_src);20857 const delta = try sema.coerce(block, Type.u32, try sema.resolveInst(extra.rhs), delta_src);
2085820858
20859 try sema.requireRuntimeBlock(block, builtin_src, null);20859 try sema.requireRuntimeBlock(block, builtin_src, null);
...@@ -20881,13 +20881,13 @@ fn resolvePrefetchOptions(...@@ -20881,13 +20881,13 @@ fn resolvePrefetchOptions(
20881 const cache_src = sema.maybeOptionsSrc(block, src, "cache");20881 const cache_src = sema.maybeOptionsSrc(block, src, "cache");
2088220882
20883 const rw = try sema.fieldVal(block, src, options, "rw", rw_src);20883 const rw = try sema.fieldVal(block, src, options, "rw", rw_src);
20884 const rw_val = try sema.resolveConstValue(block, rw_src, rw, "prefetch read/write must be comptime known");20884 const rw_val = try sema.resolveConstValue(block, rw_src, rw, "prefetch read/write must be comptime-known");
2088520885
20886 const locality = try sema.fieldVal(block, src, options, "locality", locality_src);20886 const locality = try sema.fieldVal(block, src, options, "locality", locality_src);
20887 const locality_val = try sema.resolveConstValue(block, locality_src, locality, "prefetch locality must be comptime known");20887 const locality_val = try sema.resolveConstValue(block, locality_src, locality, "prefetch locality must be comptime-known");
2088820888
20889 const cache = try sema.fieldVal(block, src, options, "cache", cache_src);20889 const cache = try sema.fieldVal(block, src, options, "cache", cache_src);
20890 const cache_val = try sema.resolveConstValue(block, cache_src, cache, "prefetch cache must be comptime known");20890 const cache_val = try sema.resolveConstValue(block, cache_src, cache, "prefetch cache must be comptime-known");
2089120891
20892 return std.builtin.PrefetchOptions{20892 return std.builtin.PrefetchOptions{
20893 .rw = rw_val.toEnum(std.builtin.PrefetchOptions.Rw),20893 .rw = rw_val.toEnum(std.builtin.PrefetchOptions.Rw),
...@@ -20947,18 +20947,18 @@ fn resolveExternOptions(...@@ -20947,18 +20947,18 @@ fn resolveExternOptions(
20947 const thread_local_src = sema.maybeOptionsSrc(block, src, "thread_local");20947 const thread_local_src = sema.maybeOptionsSrc(block, src, "thread_local");
2094820948
20949 const name_ref = try sema.fieldVal(block, src, options, "name", name_src);20949 const name_ref = try sema.fieldVal(block, src, options, "name", name_src);
20950 const name_val = try sema.resolveConstValue(block, name_src, name_ref, "name of the extern symbol must be comptime known");20950 const name_val = try sema.resolveConstValue(block, name_src, name_ref, "name of the extern symbol must be comptime-known");
20951 const name = try name_val.toAllocatedBytes(Type.initTag(.const_slice_u8), sema.arena, mod);20951 const name = try name_val.toAllocatedBytes(Type.initTag(.const_slice_u8), sema.arena, mod);
2095220952
20953 const library_name_inst = try sema.fieldVal(block, src, options, "library_name", library_src);20953 const library_name_inst = try sema.fieldVal(block, src, options, "library_name", library_src);
20954 const library_name_val = try sema.resolveConstValue(block, library_src, library_name_inst, "library in which extern symbol is must be comptime known");20954 const library_name_val = try sema.resolveConstValue(block, library_src, library_name_inst, "library in which extern symbol is must be comptime-known");
2095520955
20956 const linkage_ref = try sema.fieldVal(block, src, options, "linkage", linkage_src);20956 const linkage_ref = try sema.fieldVal(block, src, options, "linkage", linkage_src);
20957 const linkage_val = try sema.resolveConstValue(block, linkage_src, linkage_ref, "linkage of the extern symbol must be comptime known");20957 const linkage_val = try sema.resolveConstValue(block, linkage_src, linkage_ref, "linkage of the extern symbol must be comptime-known");
20958 const linkage = linkage_val.toEnum(std.builtin.GlobalLinkage);20958 const linkage = linkage_val.toEnum(std.builtin.GlobalLinkage);
2095920959
20960 const is_thread_local = try sema.fieldVal(block, src, options, "is_thread_local", thread_local_src);20960 const is_thread_local = try sema.fieldVal(block, src, options, "is_thread_local", thread_local_src);
20961 const is_thread_local_val = try sema.resolveConstValue(block, thread_local_src, is_thread_local, "threadlocality of the extern symbol must be comptime known");20961 const is_thread_local_val = try sema.resolveConstValue(block, thread_local_src, is_thread_local, "threadlocality of the extern symbol must be comptime-known");
2096220962
20963 const library_name = if (!library_name_val.isNull()) blk: {20963 const library_name = if (!library_name_val.isNull()) blk: {
20964 const payload = library_name_val.castTag(.opt_payload).?.data;20964 const payload = library_name_val.castTag(.opt_payload).?.data;
...@@ -22953,7 +22953,7 @@ fn elemPtr(...@@ -22953,7 +22953,7 @@ fn elemPtr(
22953 .Array, .Vector => return sema.elemPtrArray(block, src, indexable_ptr_src, indexable_ptr, elem_index_src, elem_index, init),22953 .Array, .Vector => return sema.elemPtrArray(block, src, indexable_ptr_src, indexable_ptr, elem_index_src, elem_index, init),
22954 .Struct => {22954 .Struct => {
22955 // Tuple field access.22955 // Tuple field access.
22956 const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, "tuple field access index must be comptime known");22956 const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, "tuple field access index must be comptime-known");
22957 const index = @intCast(u32, index_val.toUnsignedInt(target));22957 const index = @intCast(u32, index_val.toUnsignedInt(target));
22958 return sema.tupleFieldPtr(block, src, indexable_ptr, elem_index_src, index, init);22958 return sema.tupleFieldPtr(block, src, indexable_ptr, elem_index_src, index, init);
22959 },22959 },
...@@ -23015,7 +23015,7 @@ fn elemVal(...@@ -23015,7 +23015,7 @@ fn elemVal(
23015 },23015 },
23016 .Struct => {23016 .Struct => {
23017 // Tuple field access.23017 // Tuple field access.
23018 const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, "tuple field access index must be comptime known");23018 const index_val = try sema.resolveConstValue(block, elem_index_src, elem_index, "tuple field access index must be comptime-known");
23019 const index = @intCast(u32, index_val.toUnsignedInt(target));23019 const index = @intCast(u32, index_val.toUnsignedInt(target));
23020 return tupleField(sema, block, indexable_src, indexable, elem_index_src, index);23020 return tupleField(sema, block, indexable_src, indexable, elem_index_src, index);
23021 },23021 },
...@@ -23037,7 +23037,7 @@ fn validateRuntimeElemAccess(...@@ -23037,7 +23037,7 @@ fn validateRuntimeElemAccess(
23037 const msg = try sema.errMsg(23037 const msg = try sema.errMsg(
23038 block,23038 block,
23039 elem_index_src,23039 elem_index_src,
23040 "values of type '{}' must be comptime known, but index value is runtime known",23040 "values of type '{}' must be comptime-known, but index value is runtime-known",
23041 .{parent_ty.fmt(sema.mod)},23041 .{parent_ty.fmt(sema.mod)},
23042 );23042 );
23043 errdefer msg.destroy(sema.gpa);23043 errdefer msg.destroy(sema.gpa);
...@@ -23742,7 +23742,7 @@ fn coerceExtra(...@@ -23742,7 +23742,7 @@ fn coerceExtra(
23742 const val = (try sema.resolveDefinedValue(block, inst_src, inst)) orelse {23742 const val = (try sema.resolveDefinedValue(block, inst_src, inst)) orelse {
23743 if (dest_ty.zigTypeTag() == .ComptimeInt) {23743 if (dest_ty.zigTypeTag() == .ComptimeInt) {
23744 if (!opts.report_err) return error.NotCoercible;23744 if (!opts.report_err) return error.NotCoercible;
23745 return sema.failWithNeededComptime(block, inst_src, "value being casted to 'comptime_int' must be comptime known");23745 return sema.failWithNeededComptime(block, inst_src, "value being casted to 'comptime_int' must be comptime-known");
23746 }23746 }
23747 break :float;23747 break :float;
23748 };23748 };
...@@ -23760,7 +23760,7 @@ fn coerceExtra(...@@ -23760,7 +23760,7 @@ fn coerceExtra(
23760 },23760 },
23761 .Int, .ComptimeInt => {23761 .Int, .ComptimeInt => {
23762 if (try sema.resolveDefinedValue(block, inst_src, inst)) |val| {23762 if (try sema.resolveDefinedValue(block, inst_src, inst)) |val| {
23763 // comptime known integer to other number23763 // comptime-known integer to other number
23764 if (!(try sema.intFitsInType(block, inst_src, val, dest_ty, null))) {23764 if (!(try sema.intFitsInType(block, inst_src, val, dest_ty, null))) {
23765 if (!opts.report_err) return error.NotCoercible;23765 if (!opts.report_err) return error.NotCoercible;
23766 return sema.fail(block, inst_src, "type '{}' cannot represent integer value '{}'", .{ dest_ty.fmt(sema.mod), val.fmtValue(inst_ty, sema.mod) });23766 return sema.fail(block, inst_src, "type '{}' cannot represent integer value '{}'", .{ dest_ty.fmt(sema.mod), val.fmtValue(inst_ty, sema.mod) });
...@@ -23770,7 +23770,7 @@ fn coerceExtra(...@@ -23770,7 +23770,7 @@ fn coerceExtra(
23770 if (dest_ty.zigTypeTag() == .ComptimeInt) {23770 if (dest_ty.zigTypeTag() == .ComptimeInt) {
23771 if (!opts.report_err) return error.NotCoercible;23771 if (!opts.report_err) return error.NotCoercible;
23772 if (opts.no_cast_to_comptime_int) return inst;23772 if (opts.no_cast_to_comptime_int) return inst;
23773 return sema.failWithNeededComptime(block, inst_src, "value being casted to 'comptime_int' must be comptime known");23773 return sema.failWithNeededComptime(block, inst_src, "value being casted to 'comptime_int' must be comptime-known");
23774 }23774 }
2377523775
23776 // integer widening23776 // integer widening
...@@ -23809,7 +23809,7 @@ fn coerceExtra(...@@ -23809,7 +23809,7 @@ fn coerceExtra(
23809 return try sema.addConstant(dest_ty, result_val);23809 return try sema.addConstant(dest_ty, result_val);
23810 } else if (dest_ty.zigTypeTag() == .ComptimeFloat) {23810 } else if (dest_ty.zigTypeTag() == .ComptimeFloat) {
23811 if (!opts.report_err) return error.NotCoercible;23811 if (!opts.report_err) return error.NotCoercible;
23812 return sema.failWithNeededComptime(block, inst_src, "value being casted to 'comptime_float' must be comptime known");23812 return sema.failWithNeededComptime(block, inst_src, "value being casted to 'comptime_float' must be comptime-known");
23813 }23813 }
2381423814
23815 // float widening23815 // float widening
...@@ -23824,7 +23824,7 @@ fn coerceExtra(...@@ -23824,7 +23824,7 @@ fn coerceExtra(
23824 const val = (try sema.resolveDefinedValue(block, inst_src, inst)) orelse {23824 const val = (try sema.resolveDefinedValue(block, inst_src, inst)) orelse {
23825 if (dest_ty.zigTypeTag() == .ComptimeFloat) {23825 if (dest_ty.zigTypeTag() == .ComptimeFloat) {
23826 if (!opts.report_err) return error.NotCoercible;23826 if (!opts.report_err) return error.NotCoercible;
23827 return sema.failWithNeededComptime(block, inst_src, "value being casted to 'comptime_float' must be comptime known");23827 return sema.failWithNeededComptime(block, inst_src, "value being casted to 'comptime_float' must be comptime-known");
23828 }23828 }
23829 break :int;23829 break :int;
23830 };23830 };
...@@ -26620,7 +26620,7 @@ fn coerceTupleToStruct(...@@ -26620,7 +26620,7 @@ fn coerceTupleToStruct(
26620 field_refs[field_index] = coerced;26620 field_refs[field_index] = coerced;
26621 if (field.is_comptime) {26621 if (field.is_comptime) {
26622 const init_val = (try sema.resolveMaybeUndefVal(block, field_src, coerced)) orelse {26622 const init_val = (try sema.resolveMaybeUndefVal(block, field_src, coerced)) orelse {
26623 return sema.failWithNeededComptime(block, field_src, "value stored in comptime field must be comptime known");26623 return sema.failWithNeededComptime(block, field_src, "value stored in comptime field must be comptime-known");
26624 };26624 };
2662526625
26626 if (!init_val.eql(field.default_val, field.ty, sema.mod)) {26626 if (!init_val.eql(field.default_val, field.ty, sema.mod)) {
...@@ -26716,7 +26716,7 @@ fn coerceTupleToTuple(...@@ -26716,7 +26716,7 @@ fn coerceTupleToTuple(
26716 field_refs[field_index] = coerced;26716 field_refs[field_index] = coerced;
26717 if (default_val.tag() != .unreachable_value) {26717 if (default_val.tag() != .unreachable_value) {
26718 const init_val = (try sema.resolveMaybeUndefVal(block, field_src, coerced)) orelse {26718 const init_val = (try sema.resolveMaybeUndefVal(block, field_src, coerced)) orelse {
26719 return sema.failWithNeededComptime(block, field_src, "value stored in comptime field must be comptime known");26719 return sema.failWithNeededComptime(block, field_src, "value stored in comptime field must be comptime-known");
26720 };26720 };
2672126721
26722 if (!init_val.eql(default_val, field_ty, sema.mod)) {26722 if (!init_val.eql(default_val, field_ty, sema.mod)) {
...@@ -27086,7 +27086,7 @@ fn analyzeIsNonErrComptimeOnly(...@@ -27086,7 +27086,7 @@ fn analyzeIsNonErrComptimeOnly(
27086 const maybe_operand_val = try sema.resolveMaybeUndefVal(block, src, operand);27086 const maybe_operand_val = try sema.resolveMaybeUndefVal(block, src, operand);
2708727087
27088 // exception if the error union error set is known to be empty,27088 // exception if the error union error set is known to be empty,
27089 // we allow the comparison but always make it comptime known.27089 // we allow the comparison but always make it comptime-known.
27090 const set_ty = operand_ty.errorUnionSet();27090 const set_ty = operand_ty.errorUnionSet();
27091 switch (set_ty.tag()) {27091 switch (set_ty.tag()) {
27092 .anyerror => {},27092 .anyerror => {},
...@@ -27353,7 +27353,7 @@ fn analyzeSlice(...@@ -27353,7 +27353,7 @@ fn analyzeSlice(
27353 const sentinel = s: {27353 const sentinel = s: {
27354 if (sentinel_opt != .none) {27354 if (sentinel_opt != .none) {
27355 const casted = try sema.coerce(block, elem_ty, sentinel_opt, sentinel_src);27355 const casted = try sema.coerce(block, elem_ty, sentinel_opt, sentinel_src);
27356 break :s try sema.resolveConstValue(block, sentinel_src, casted, "slice sentinel must be comptime known");27356 break :s try sema.resolveConstValue(block, sentinel_src, casted, "slice sentinel must be comptime-known");
27357 }27357 }
27358 // If we are slicing to the end of something that is sentinel-terminated27358 // If we are slicing to the end of something that is sentinel-terminated
27359 // then the resulting slice type is also sentinel-terminated.27359 // then the resulting slice type is also sentinel-terminated.
...@@ -27616,7 +27616,7 @@ fn cmpNumeric(...@@ -27616,7 +27616,7 @@ fn cmpNumeric(
27616 };27616 };
2761727617
27618 // TODO handle comparisons against lazy zero values27618 // TODO handle comparisons against lazy zero values
27619 // Some values can be compared against zero without being runtime known or without forcing27619 // Some values can be compared against zero without being runtime-known or without forcing
27620 // a full resolution of their value, for example `@sizeOf(@Frame(function))` is known to27620 // a full resolution of their value, for example `@sizeOf(@Frame(function))` is known to
27621 // always be nonzero, and we benefit from not forcing the full evaluation and stack frame layout27621 // always be nonzero, and we benefit from not forcing the full evaluation and stack frame layout
27622 // of this function if we don't need to.27622 // of this function if we don't need to.
...@@ -29275,7 +29275,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void...@@ -29275,7 +29275,7 @@ fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void
29275 const field = &struct_obj.fields.values()[i];29275 const field = &struct_obj.fields.values()[i];
29276 const coerced = try sema.coerce(&block_scope, field.ty, init, src);29276 const coerced = try sema.coerce(&block_scope, field.ty, init, src);
29277 const default_val = (try sema.resolveMaybeUndefVal(&block_scope, src, coerced)) orelse29277 const default_val = (try sema.resolveMaybeUndefVal(&block_scope, src, coerced)) orelse
29278 return sema.failWithNeededComptime(&block_scope, src, "struct field default value must be comptime known");29278 return sema.failWithNeededComptime(&block_scope, src, "struct field default value must be comptime-known");
29279 field.default_val = try default_val.copy(decl_arena_allocator);29279 field.default_val = try default_val.copy(decl_arena_allocator);
29280 }29280 }
29281 }29281 }
...@@ -29471,7 +29471,7 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {...@@ -29471,7 +29471,7 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void {
29471 if (tag_ref != .none) {29471 if (tag_ref != .none) {
29472 const tag_src = src; // TODO better source location29472 const tag_src = src; // TODO better source location
29473 const coerced = try sema.coerce(&block_scope, int_tag_ty, tag_ref, tag_src);29473 const coerced = try sema.coerce(&block_scope, int_tag_ty, tag_ref, tag_src);
29474 const val = try sema.resolveConstValue(&block_scope, tag_src, coerced, "enum tag value must be comptime known");29474 const val = try sema.resolveConstValue(&block_scope, tag_src, coerced, "enum tag value must be comptime-known");
29475 last_tag_val = val;29475 last_tag_val = val;
2947629476
29477 // This puts the memory into the union arena, not the enum arena, but29477 // This puts the memory into the union arena, not the enum arena, but
...@@ -30295,7 +30295,7 @@ pub fn analyzeAddrspace(...@@ -30295,7 +30295,7 @@ pub fn analyzeAddrspace(
30295 zir_ref: Zir.Inst.Ref,30295 zir_ref: Zir.Inst.Ref,
30296 ctx: AddressSpaceContext,30296 ctx: AddressSpaceContext,
30297) !std.builtin.AddressSpace {30297) !std.builtin.AddressSpace {
30298 const addrspace_tv = try sema.resolveInstConst(block, src, zir_ref, "addresspace must be comptime known");30298 const addrspace_tv = try sema.resolveInstConst(block, src, zir_ref, "addresspace must be comptime-known");
30299 const address_space = addrspace_tv.val.toEnum(std.builtin.AddressSpace);30299 const address_space = addrspace_tv.val.toEnum(std.builtin.AddressSpace);
30300 const target = sema.mod.getTarget();30300 const target = sema.mod.getTarget();
30301 const arch = target.cpu.arch;30301 const arch = target.cpu.arch;
src/arch/aarch64/CodeGen.zig+1-1
...@@ -5425,7 +5425,7 @@ fn parseRegName(name: []const u8) ?Register {...@@ -5425,7 +5425,7 @@ fn parseRegName(name: []const u8) ?Register {
54255425
5426fn registerAlias(reg: Register, size_bytes: u64) Register {5426fn registerAlias(reg: Register, size_bytes: u64) Register {
5427 if (size_bytes == 0) {5427 if (size_bytes == 0) {
5428 unreachable; // should be comptime known5428 unreachable; // should be comptime-known
5429 } else if (size_bytes <= 4) {5429 } else if (size_bytes <= 4) {
5430 return reg.to32();5430 return reg.to32();
5431 } else if (size_bytes <= 8) {5431 } else if (size_bytes <= 8) {
src/arch/riscv64/CodeGen.zig+1-1
...@@ -1769,7 +1769,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions....@@ -1769,7 +1769,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.
1769 return self.fail("TODO implement calling bitcasted functions", .{});1769 return self.fail("TODO implement calling bitcasted functions", .{});
1770 }1770 }
1771 } else {1771 } else {
1772 return self.fail("TODO implement calling runtime known function pointer", .{});1772 return self.fail("TODO implement calling runtime-known function pointer", .{});
1773 }1773 }
1774 } else if (self.bin_file.cast(link.File.Coff)) |_| {1774 } else if (self.bin_file.cast(link.File.Coff)) |_| {
1775 return self.fail("TODO implement calling in COFF for {}", .{self.target.cpu.arch});1775 return self.fail("TODO implement calling in COFF for {}", .{self.target.cpu.arch});
src/arch/x86_64/CodeGen.zig+1-1
...@@ -7272,7 +7272,7 @@ fn parseRegName(name: []const u8) ?Register {...@@ -7272,7 +7272,7 @@ fn parseRegName(name: []const u8) ?Register {
7272/// Returns register wide enough to hold at least `size_bytes`.7272/// Returns register wide enough to hold at least `size_bytes`.
7273fn registerAlias(reg: Register, size_bytes: u32) Register {7273fn registerAlias(reg: Register, size_bytes: u32) Register {
7274 if (size_bytes == 0) {7274 if (size_bytes == 0) {
7275 unreachable; // should be comptime known7275 unreachable; // should be comptime-known
7276 } else if (size_bytes <= 1) {7276 } else if (size_bytes <= 1) {
7277 return reg.to8();7277 return reg.to8();
7278 } else if (size_bytes <= 2) {7278 } else if (size_bytes <= 2) {
src/link.zig+1-1
...@@ -305,7 +305,7 @@ pub const File = struct {...@@ -305,7 +305,7 @@ pub const File = struct {
305 };305 };
306 }306 }
307 const emit = options.emit.?;307 const emit = options.emit.?;
308 const use_lld = build_options.have_llvm and options.use_lld; // comptime known false when !have_llvm308 const use_lld = build_options.have_llvm and options.use_lld; // comptime-known false when !have_llvm
309 const sub_path = if (use_lld) blk: {309 const sub_path = if (use_lld) blk: {
310 if (options.module == null) {310 if (options.module == null) {
311 // No point in opening a file, we would not write anything to it.311 // No point in opening a file, we would not write anything to it.
src/tracy.zig+2-2
...@@ -173,13 +173,13 @@ pub fn TracyAllocator(comptime name: ?[:0]const u8) type {...@@ -173,13 +173,13 @@ pub fn TracyAllocator(comptime name: ?[:0]const u8) type {
173 };173 };
174}174}
175175
176// This function only accepts comptime known strings, see `messageCopy` for runtime strings176// This function only accepts comptime-known strings, see `messageCopy` for runtime strings
177pub inline fn message(comptime msg: [:0]const u8) void {177pub inline fn message(comptime msg: [:0]const u8) void {
178 if (!enable) return;178 if (!enable) return;
179 ___tracy_emit_messageL(msg.ptr, if (enable_callstack) callstack_depth else 0);179 ___tracy_emit_messageL(msg.ptr, if (enable_callstack) callstack_depth else 0);
180}180}
181181
182// This function only accepts comptime known strings, see `messageColorCopy` for runtime strings182// This function only accepts comptime-known strings, see `messageColorCopy` for runtime strings
183pub inline fn messageColor(comptime msg: [:0]const u8, color: u32) void {183pub inline fn messageColor(comptime msg: [:0]const u8, color: u32) void {
184 if (!enable) return;184 if (!enable) return;
185 ___tracy_emit_messageLC(msg.ptr, color, if (enable_callstack) callstack_depth else 0);185 ___tracy_emit_messageLC(msg.ptr, color, if (enable_callstack) callstack_depth else 0);
src/type.zig+1-1
...@@ -2318,7 +2318,7 @@ pub const Type = extern union {...@@ -2318,7 +2318,7 @@ pub const Type = extern union {
2318 /// * the type has only one possible value, making its ABI size 0.2318 /// * the type has only one possible value, making its ABI size 0.
2319 /// - an enum with an explicit tag type has the ABI size of the integer tag type,2319 /// - an enum with an explicit tag type has the ABI size of the integer tag type,
2320 /// making it one-possible-value only if the integer tag type has 0 bits.2320 /// making it one-possible-value only if the integer tag type has 0 bits.
2321 /// When `ignore_comptime_only` is true, then types that are comptime only2321 /// When `ignore_comptime_only` is true, then types that are comptime-only
2322 /// may return false positives.2322 /// may return false positives.
2323 pub fn hasRuntimeBitsAdvanced(2323 pub fn hasRuntimeBitsAdvanced(
2324 ty: Type,2324 ty: Type,
test/behavior/align.zig+1-1
...@@ -400,7 +400,7 @@ test "function callconv expression depends on generic parameter" {...@@ -400,7 +400,7 @@ test "function callconv expression depends on generic parameter" {
400 comptime try S.doTheTest();400 comptime try S.doTheTest();
401}401}
402402
403test "runtime known array index has best alignment possible" {403test "runtime-known array index has best alignment possible" {
404 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO404 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
405405
406 // take full advantage of over-alignment406 // take full advantage of over-alignment
test/behavior/array.zig+1-1
...@@ -564,7 +564,7 @@ test "type coercion of pointer to anon struct literal to pointer to array" {...@@ -564,7 +564,7 @@ test "type coercion of pointer to anon struct literal to pointer to array" {
564 comptime try S.doTheTest();564 comptime try S.doTheTest();
565}565}
566566
567test "array with comptime only element type" {567test "array with comptime-only element type" {
568 const a = [_]type{ u32, i32 };568 const a = [_]type{ u32, i32 };
569 try testing.expect(a[0] == u32);569 try testing.expect(a[0] == u32);
570 try testing.expect(a[1] == i32);570 try testing.expect(a[1] == i32);
test/behavior/basic.zig+1-1
...@@ -999,7 +999,7 @@ test "generic function uses return type of other generic function" {...@@ -999,7 +999,7 @@ test "generic function uses return type of other generic function" {
999 try std.testing.expect(S.call(S.func, .{@as(u8, 1)}) == 1);999 try std.testing.expect(S.call(S.func, .{@as(u8, 1)}) == 1);
1000}1000}
10011001
1002test "const alloc with comptime known initializer is made comptime known" {1002test "const alloc with comptime-known initializer is made comptime-known" {
1003 const S = struct {1003 const S = struct {
1004 a: bool,1004 a: bool,
1005 b: [2]u8,1005 b: [2]u8,
test/behavior/enum.zig+2-2
...@@ -846,12 +846,12 @@ fn doALoopThing(id: EnumWithOneMember) void {...@@ -846,12 +846,12 @@ fn doALoopThing(id: EnumWithOneMember) void {
846 }846 }
847}847}
848848
849test "comparison operator on enum with one member is comptime known" {849test "comparison operator on enum with one member is comptime-known" {
850 doALoopThing(EnumWithOneMember.Eof);850 doALoopThing(EnumWithOneMember.Eof);
851}851}
852852
853const State = enum { Start };853const State = enum { Start };
854test "switch on enum with one member is comptime known" {854test "switch on enum with one member is comptime-known" {
855 var state = State.Start;855 var state = State.Start;
856 switch (state) {856 switch (state) {
857 State.Start => return,857 State.Start => return,
test/behavior/eval.zig+5-5
...@@ -582,16 +582,16 @@ test "comparisons 0 <= uint and 0 > uint should be comptime" {...@@ -582,16 +582,16 @@ test "comparisons 0 <= uint and 0 > uint should be comptime" {
582}582}
583fn testCompTimeUIntComparisons(x: u32) void {583fn testCompTimeUIntComparisons(x: u32) void {
584 if (!(0 <= x)) {584 if (!(0 <= x)) {
585 @compileError("this condition should be comptime known");585 @compileError("this condition should be comptime-known");
586 }586 }
587 if (0 > x) {587 if (0 > x) {
588 @compileError("this condition should be comptime known");588 @compileError("this condition should be comptime-known");
589 }589 }
590 if (!(x >= 0)) {590 if (!(x >= 0)) {
591 @compileError("this condition should be comptime known");591 @compileError("this condition should be comptime-known");
592 }592 }
593 if (x < 0) {593 if (x < 0) {
594 @compileError("this condition should be comptime known");594 @compileError("this condition should be comptime-known");
595 }595 }
596}596}
597597
...@@ -1302,7 +1302,7 @@ test "repeated value is correctly expanded" {...@@ -1302,7 +1302,7 @@ test "repeated value is correctly expanded" {
1302 }1302 }
1303}1303}
13041304
1305test "value in if block is comptime known" {1305test "value in if block is comptime-known" {
1306 if (builtin.zig_backend == .stage1) return error.SkipZigTest;1306 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
13071307
1308 const first = blk: {1308 const first = blk: {
test/behavior/math.zig+1-1
...@@ -990,7 +990,7 @@ test "overflow arithmetic with u0 values" {...@@ -990,7 +990,7 @@ test "overflow arithmetic with u0 values" {
990 try expect(result == 0);990 try expect(result == 0);
991}991}
992992
993test "allow signed integer division/remainder when values are comptime known and positive or exact" {993test "allow signed integer division/remainder when values are comptime-known and positive or exact" {
994 if (builtin.zig_backend == .stage1) return error.SkipZigTest;994 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
995995
996 try expect(5 / 3 == 1);996 try expect(5 / 3 == 1);
test/behavior/struct.zig+1-1
...@@ -653,7 +653,7 @@ test "default struct initialization fields" {...@@ -653,7 +653,7 @@ test "default struct initialization fields" {
653 .b = five,653 .b = five,
654 };654 };
655 if (x.a + x.b != 1239) {655 if (x.a + x.b != 1239) {
656 @compileError("it should be comptime known");656 @compileError("it should be comptime-known");
657 }657 }
658 try expect(y.a == x.a);658 try expect(y.a == x.a);
659 try expect(y.b == x.b);659 try expect(y.b == x.b);
test/behavior/truncate.zig+2-2
...@@ -2,7 +2,7 @@ const std = @import("std");...@@ -2,7 +2,7 @@ const std = @import("std");
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const expect = std.testing.expect;3const expect = std.testing.expect;
44
5test "truncate u0 to larger integer allowed and has comptime known result" {5test "truncate u0 to larger integer allowed and has comptime-known result" {
6 var x: u0 = 0;6 var x: u0 = 0;
7 const y = @truncate(u8, x);7 const y = @truncate(u8, x);
8 comptime try expect(y == 0);8 comptime try expect(y == 0);
...@@ -25,7 +25,7 @@ test "truncate.u0.var" {...@@ -25,7 +25,7 @@ test "truncate.u0.var" {
25 try expect(z == 0);25 try expect(z == 0);
26}26}
2727
28test "truncate i0 to larger integer allowed and has comptime known result" {28test "truncate i0 to larger integer allowed and has comptime-known result" {
29 var x: i0 = 0;29 var x: i0 = 0;
30 const y = @truncate(i8, x);30 const y = @truncate(i8, x);
31 comptime try expect(y == 0);31 comptime try expect(y == 0);
test/cases/compile_errors/dereference_anyopaque.zig+4-4
...@@ -45,11 +45,11 @@ pub export fn entry() void {...@@ -45,11 +45,11 @@ pub export fn entry() void {
45// backend=llvm45// backend=llvm
46//46//
47// :11:22: error: comparison of 'void' with null47// :11:22: error: comparison of 'void' with null
48// :25:51: error: values of type 'anyopaque' must be comptime known, but operand value is runtime known48// :25:51: error: values of type 'anyopaque' must be comptime-known, but operand value is runtime-known
49// :25:51: note: opaque type 'anyopaque' has undefined size49// :25:51: note: opaque type 'anyopaque' has undefined size
50// :25:51: error: values of type 'fn(*anyopaque, usize, u29, u29, usize) error{OutOfMemory}![]u8' must be comptime known, but operand value is runtime known50// :25:51: error: values of type 'fn(*anyopaque, usize, u29, u29, usize) error{OutOfMemory}![]u8' must be comptime-known, but operand value is runtime-known
51// :25:51: note: use '*const fn(*anyopaque, usize, u29, u29, usize) error{OutOfMemory}![]u8' for a function pointer type51// :25:51: note: use '*const fn(*anyopaque, usize, u29, u29, usize) error{OutOfMemory}![]u8' for a function pointer type
52// :25:51: error: values of type 'fn(*anyopaque, []u8, u29, usize, u29, usize) ?usize' must be comptime known, but operand value is runtime known52// :25:51: error: values of type 'fn(*anyopaque, []u8, u29, usize, u29, usize) ?usize' must be comptime-known, but operand value is runtime-known
53// :25:51: note: use '*const fn(*anyopaque, []u8, u29, usize, u29, usize) ?usize' for a function pointer type53// :25:51: note: use '*const fn(*anyopaque, []u8, u29, usize, u29, usize) ?usize' for a function pointer type
54// :25:51: error: values of type 'fn(*anyopaque, []u8, u29, usize) void' must be comptime known, but operand value is runtime known54// :25:51: error: values of type 'fn(*anyopaque, []u8, u29, usize) void' must be comptime-known, but operand value is runtime-known
55// :25:51: note: use '*const fn(*anyopaque, []u8, u29, usize) void' for a function pointer type55// :25:51: note: use '*const fn(*anyopaque, []u8, u29, usize) void' for a function pointer type
test/cases/compile_errors/error_in_typeof_param.zig+1-1
...@@ -11,4 +11,4 @@ pub export fn entry() void {...@@ -11,4 +11,4 @@ pub export fn entry() void {
11// target=native11// target=native
12//12//
13// :6:31: error: unable to resolve comptime value13// :6:31: error: unable to resolve comptime value
14// :6:31: note: argument to parameter with comptime only type must be comptime known14// :6:31: note: argument to parameter with comptime-only type must be comptime-known
test/cases/compile_errors/explain_why_fn_is_called_at_comptime.zig+2-2
...@@ -17,7 +17,7 @@ pub export fn entry() void {...@@ -17,7 +17,7 @@ pub export fn entry() void {
17// target=native17// target=native
18//18//
19// :12:13: error: unable to resolve comptime value19// :12:13: error: unable to resolve comptime value
20// :12:13: note: argument to function being called at comptime must be comptime known20// :12:13: note: argument to function being called at comptime must be comptime-known
21// :7:25: note: function is being called at comptime because it returns a comptime only type 'tmp.S'21// :7:25: note: function is being called at comptime because it returns a comptime-only type 'tmp.S'
22// :2:12: note: struct requires comptime because of this field22// :2:12: note: struct requires comptime because of this field
23// :2:12: note: use '*const fn() void' for a function pointer type23// :2:12: note: use '*const fn() void' for a function pointer type
test/cases/compile_errors/explain_why_generic_fn_is_called_at_comptime.zig+2-2
...@@ -18,5 +18,5 @@ pub export fn entry() void {...@@ -18,5 +18,5 @@ pub export fn entry() void {
18// target=native18// target=native
19//19//
20// :14:13: error: unable to resolve comptime value20// :14:13: error: unable to resolve comptime value
21// :14:13: note: argument to function being called at comptime must be comptime known21// :14:13: note: argument to function being called at comptime must be comptime-known
22// :9:38: note: generic function is instantiated with a comptime only return type22// :9:38: note: generic function is instantiated with a comptime-only return type
test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig+2-2
...@@ -12,6 +12,6 @@ export fn bar() void {...@@ -12,6 +12,6 @@ export fn bar() void {
12// target=native12// target=native
13//13//
14// :3:35: error: unable to resolve comptime value14// :3:35: error: unable to resolve comptime value
15// :3:35: note: value being casted to 'comptime_int' must be comptime known15// :3:35: note: value being casted to 'comptime_int' must be comptime-known
16// :7:37: error: unable to resolve comptime value16// :7:37: error: unable to resolve comptime value
17// :7:37: note: value being casted to 'comptime_float' must be comptime known17// :7:37: note: value being casted to 'comptime_float' must be comptime-known
test/cases/compile_errors/non-comptime-parameter-used-as-array-size.zig+1-1
...@@ -12,4 +12,4 @@ fn makeLlamas(count: usize) [count]u8 {...@@ -12,4 +12,4 @@ fn makeLlamas(count: usize) [count]u8 {
12// target=native12// target=native
13//13//
14// :8:30: error: unable to resolve comptime value14// :8:30: error: unable to resolve comptime value
15// :8:30: note: array length must be comptime known15// :8:30: note: array length must be comptime-known
test/cases/compile_errors/non-const_switch_number_literal.zig+1-1
...@@ -14,5 +14,5 @@ fn bar() i32 {...@@ -14,5 +14,5 @@ fn bar() i32 {
14// backend=stage214// backend=stage2
15// target=native15// target=native
16//16//
17// :2:15: error: value with comptime only type 'comptime_int' depends on runtime control flow17// :2:15: error: value with comptime-only type 'comptime_int' depends on runtime control flow
18// :2:26: note: runtime control flow here18// :2:26: note: runtime control flow here
test/cases/compile_errors/non-const_variables_of_things_that_require_const_variables.zig+1-1
...@@ -39,7 +39,7 @@ const Opaque = opaque {};...@@ -39,7 +39,7 @@ const Opaque = opaque {};
39// :14:8: error: variable of type 'comptime_float' must be const or comptime39// :14:8: error: variable of type 'comptime_float' must be const or comptime
40// :14:8: note: to modify this variable at runtime, it must be given an explicit fixed-size number type40// :14:8: note: to modify this variable at runtime, it must be given an explicit fixed-size number type
41// :18:8: error: variable of type '@TypeOf(null)' must be const or comptime41// :18:8: error: variable of type '@TypeOf(null)' must be const or comptime
42// :22:19: error: values of type 'tmp.Opaque' must be comptime known, but operand value is runtime known42// :22:19: error: values of type 'tmp.Opaque' must be comptime-known, but operand value is runtime-known
43// :22:19: note: opaque type 'tmp.Opaque' has undefined size43// :22:19: note: opaque type 'tmp.Opaque' has undefined size
44// :26:8: error: variable of type 'type' must be const or comptime44// :26:8: error: variable of type 'type' must be const or comptime
45// :26:8: note: types are not available at runtime45// :26:8: note: types are not available at runtime
test/cases/compile_errors/non-inline_for_loop_on_a_type_that_requires_comptime.zig+1-1
...@@ -11,6 +11,6 @@ export fn entry() void {...@@ -11,6 +11,6 @@ export fn entry() void {
11// backend=stage211// backend=stage2
12// target=native12// target=native
13//13//
14// :7:10: error: values of type '[2]tmp.Foo' must be comptime known, but index value is runtime known14// :7:10: error: values of type '[2]tmp.Foo' must be comptime-known, but index value is runtime-known
15// :3:8: note: struct requires comptime because of this field15// :3:8: note: struct requires comptime because of this field
16// :3:8: note: types are not available at runtime16// :3:8: note: types are not available at runtime
test/cases/compile_errors/non_comptime_param_in_comptime_function.zig+2-2
...@@ -26,10 +26,10 @@ export fn entry2() void {...@@ -26,10 +26,10 @@ export fn entry2() void {
26// backend=stage226// backend=stage2
27// target=native27// target=native
28//28//
29// :1:20: error: function with comptime only return type 'type' requires all parameters to be comptime29// :1:20: error: function with comptime-only return type 'type' requires all parameters to be comptime
30// :1:20: note: types are not available at runtime30// :1:20: note: types are not available at runtime
31// :1:6: note: param 'val' is required to be comptime31// :1:6: note: param 'val' is required to be comptime
32// :11:16: error: function with comptime only return type 'tmp.S' requires all parameters to be comptime32// :11:16: error: function with comptime-only return type 'tmp.S' requires all parameters to be comptime
33// :9:10: note: struct requires comptime because of this field33// :9:10: note: struct requires comptime because of this field
34// :9:10: note: use '*const fn() void' for a function pointer type34// :9:10: note: use '*const fn() void' for a function pointer type
35// :11:8: note: param is required to be comptime35// :11:8: note: param is required to be comptime
test/cases/compile_errors/runtime_index_into_comptime_type_slice.zig+1-1
...@@ -14,6 +14,6 @@ export fn entry() void {...@@ -14,6 +14,6 @@ export fn entry() void {
14// backend=stage214// backend=stage2
15// target=native15// target=native
16//16//
17// :9:51: error: values of type '[]const builtin.Type.StructField' must be comptime known, but index value is runtime known17// :9:51: error: values of type '[]const builtin.Type.StructField' must be comptime-known, but index value is runtime-known
18// :?:21: note: struct requires comptime because of this field18// :?:21: note: struct requires comptime because of this field
19// :?:21: note: types are not available at runtime19// :?:21: note: types are not available at runtime
test/cases/compile_errors/runtime_indexing_comptime_array.zig+3-3
...@@ -24,9 +24,9 @@ pub export fn entry3() void {...@@ -24,9 +24,9 @@ pub export fn entry3() void {
24// target=native24// target=native
25// backend=stage225// backend=stage2
26//26//
27// :7:10: error: values of type '[2]fn() void' must be comptime known, but index value is runtime known27// :7:10: error: values of type '[2]fn() void' must be comptime-known, but index value is runtime-known
28// :7:10: note: use '*const fn() void' for a function pointer type28// :7:10: note: use '*const fn() void' for a function pointer type
29// :15:18: error: values of type '[2]fn() void' must be comptime known, but index value is runtime known29// :15:18: error: values of type '[2]fn() void' must be comptime-known, but index value is runtime-known
30// :15:17: note: use '*const fn() void' for a function pointer type30// :15:17: note: use '*const fn() void' for a function pointer type
31// :21:19: error: values of type '[2]fn() void' must be comptime known, but index value is runtime known31// :21:19: error: values of type '[2]fn() void' must be comptime-known, but index value is runtime-known
32// :21:18: note: use '*const fn() void' for a function pointer type32// :21:18: note: use '*const fn() void' for a function pointer type
test/cases/compile_errors/runtime_to_comptime_num.zig+4-4
...@@ -22,10 +22,10 @@ pub export fn entry4() void{...@@ -22,10 +22,10 @@ pub export fn entry4() void{
22// target=native22// target=native
23//23//
24// :3:27: error: unable to resolve comptime value24// :3:27: error: unable to resolve comptime value
25// :3:27: note: value being casted to 'comptime_int' must be comptime known25// :3:27: note: value being casted to 'comptime_int' must be comptime-known
26// :7:29: error: unable to resolve comptime value26// :7:29: error: unable to resolve comptime value
27// :7:29: note: value being casted to 'comptime_float' must be comptime known27// :7:29: note: value being casted to 'comptime_float' must be comptime-known
28// :12:10: error: unable to resolve comptime value28// :12:10: error: unable to resolve comptime value
29// :12:10: note: value being casted to 'comptime_float' must be comptime known29// :12:10: note: value being casted to 'comptime_float' must be comptime-known
30// :17:10: error: unable to resolve comptime value30// :17:10: error: unable to resolve comptime value
31// :17:10: note: value being casted to 'comptime_int' must be comptime known31// :17:10: note: value being casted to 'comptime_int' must be comptime-known
test/cases/compile_errors/shifting_without_int_type_or_comptime_known.zig+4-4
...@@ -17,7 +17,7 @@ export fn entry3() void {...@@ -17,7 +17,7 @@ export fn entry3() void {
17// backend=stage217// backend=stage2
18// target=native18// target=native
19//19//
20// :2:17: error: LHS of shift must be a fixed-width integer type, or RHS must be a comptime known20// :2:17: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
21// :5:17: error: LHS of shift must be a fixed-width integer type, or RHS must be a comptime known21// :5:17: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
22// :9:9: error: LHS of shift must be a fixed-width integer type, or RHS must be a comptime known22// :9:9: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
23// :13:9: error: LHS of shift must be a fixed-width integer type, or RHS must be a comptime known23// :13:9: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
test/cases/x86_64-linux/assert_function.8.zig+1-1
...@@ -22,4 +22,4 @@ pub fn assert(ok: bool) void {...@@ -22,4 +22,4 @@ pub fn assert(ok: bool) void {
22// error22// error
23//23//
24// :3:21: error: unable to resolve comptime value24// :3:21: error: unable to resolve comptime value
25// :3:21: note: condition in comptime branch must be comptime known25// :3:21: note: condition in comptime branch must be comptime-known
test/cases/x86_64-macos/assert_function.8.zig+1-1
...@@ -17,4 +17,4 @@ pub fn assert(ok: bool) void {...@@ -17,4 +17,4 @@ pub fn assert(ok: bool) void {
17// error17// error
18//18//
19// :5:21: error: unable to resolve comptime value19// :5:21: error: unable to resolve comptime value
20// :5:21: note: condition in comptime branch must be comptime known20// :5:21: note: condition in comptime branch must be comptime-known
test/compile_errors.zig+2-2
...@@ -203,8 +203,8 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -203,8 +203,8 @@ pub fn addCases(ctx: *TestContext) !void {
203 \\}203 \\}
204 , &[_][]const u8{204 , &[_][]const u8{
205 ":3:12: error: unable to resolve comptime value",205 ":3:12: error: unable to resolve comptime value",
206 ":3:12: note: argument to function being called at comptime must be comptime known",206 ":3:12: note: argument to function being called at comptime must be comptime-known",
207 ":2:55: note: generic function is instantiated with a comptime only return type",207 ":2:55: note: generic function is instantiated with a comptime-only return type",
208 });208 });
209 }209 }
210210