| ... | @@ -50,7 +50,7 @@ comptime_break_inst: Zir.Inst.Index = undefined, | ... | @@ -50,7 +50,7 @@ comptime_break_inst: Zir.Inst.Index = undefined, |
| 50 | src: LazySrcLoc = .{ .token_offset = 0 }, | 50 | src: LazySrcLoc = .{ .token_offset = 0 }, |
| 51 | decl_val_table: std.AutoHashMapUnmanaged(Decl.Index, Air.Inst.Ref) = .{}, | 51 | decl_val_table: std.AutoHashMapUnmanaged(Decl.Index, Air.Inst.Ref) = .{}, |
| 52 | /// When doing a generic function instantiation, this array collects a | 52 | /// When doing a generic function instantiation, this array collects a |
| 53 | /// `Value` object for each parameter that is comptime known and thus elided | 53 | /// `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` and | 54 | /// 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. |
| 56 | comptime_args: []TypedValue = &.{}, | 56 | comptime_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; |
| 1386 | | 1386 | |
| 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 location | 2741 | // 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; |
| 3261 | | 3261 | |
| 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, the | 3479 | // 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 = constant | 3482 | // %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 | } |
| 4599 | | 4599 | |
| 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 | } |
| 4602 | | 4602 | |
| 4603 | fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 4603 | fn 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 | } |
| 4609 | | 4609 | |
| ... | @@ -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 | } |
| 4762 | | 4762 | |
| ... | @@ -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); |
| 5101 | | 5101 | |
| 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 |
| 5347 | fn zirSetCold(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 5347 | fn 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 function | 5351 | 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 |
| 5355 | fn zirSetFloatMode(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void { | 5355 | fn 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 | } |
| 5360 | | 5360 | |
| 5361 | fn zirSetRuntimeSafety(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 5361 | fn 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 | } |
| 5366 | | 5366 | |
| 5367 | fn zirFence(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void { | 5367 | fn 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 |
| 5369 | | 5369 | |
| 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"); |
| 5373 | | 5373 | |
| 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 | } |
| 6007 | | 6007 | |
| 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); |
| 6416 | | 6416 | |
| 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); |
| 6451 | | 6451 | |
| 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; |
| 6538 | | 6538 | |
| 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); |
| 7054 | | 7054 | |
| ... | @@ -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); |
| 7073 | | 7073 | |
| 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; |
| 7754 | | 7754 | |
| 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 | } |
| 8077 | | 8077 | |
| 8078 | // If the return type is comptime only but not dependent on parameters then all parameter types also need to be comptime | 8078 | // 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 | } |
| 8592 | | 8592 | |
| ... | @@ -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 | } |
| 8605 | | 8605 | |
| ... | @@ -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 | } |
| 8617 | | 8617 | |
| ... | @@ -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); |
| 10941 | | 10941 | |
| 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"); |
| 10982 | | 10982 | |
| 10983 | try checkNamespaceType(sema, block, lhs_src, container_type); | 10983 | try checkNamespaceType(sema, block, lhs_src, container_type); |
| 10984 | | 10984 | |
| ... | @@ -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"); |
| 11046 | | 11046 | |
| 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; |
| 11340 | | 11340 | |
| 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 | } |
| 11344 | | 11344 | |
| 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 based | 11746 | // 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 }; |
| 11848 | | 11848 | |
| 11849 | // In `**` rhs must be comptime-known, but lhs can be runtime-known | 11849 | // 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"); |
| 11851 | | 11851 | |
| 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; |
| 16228 | | 16228 | |
| 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, in | 16234 | // 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; |
| 16258 | | 16258 | |
| 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; |
| 16265 | | 16265 | |
| ... | @@ -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 | }; |
| 16486 | | 16486 | |
| 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 | } |
| 16998 | | 16998 | |
| ... | @@ -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 | } |
| 18218 | | 18218 | |
| 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 | } |
| 18251 | | 18251 | |
| 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; |
| 18827 | | 18827 | |
| 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(); |
| 18831 | | 18831 | |
| 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"); |
| 19302 | | 19302 | |
| 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); |
| 19307 | | 19307 | |
| 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); |
| 19311 | | 19311 | |
| 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"); |
| 19314 | | 19314 | |
| 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); |
| 19318 | | 19318 | |
| 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 | } |
| 19374 | | 19374 | |
| 19375 | fn zirCmpxchg( | 19375 | fn 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"); |
| 19410 | | 19410 | |
| 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 | } |
| 19590 | | 19590 | |
| ... | @@ -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"); |
| 19856 | | 19856 | |
| 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"); |
| 19920 | | 19920 | |
| 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"); |
| 19988 | | 19988 | |
| 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"); |
| 20088 | | 20088 | |
| 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); |
| 20092 | | 20092 | |
| 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"); |
| 20095 | | 20095 | |
| 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 }; |
| 20222 | | 20222 | |
| 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); |
| 20227 | | 20227 | |
| ... | @@ -20538,7 +20538,7 @@ fn zirVarExtended( | ... | @@ -20538,7 +20538,7 @@ fn zirVarExtended( |
| 20538 | uncasted_init; | 20538 | uncasted_init; |
| 20539 | | 20539 | |
| 20540 | break :blk (try sema.resolveMaybeUndefVal(block, init_src, init)) orelse | 20540 | 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); |
| 20543 | | 20543 | |
| 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; |
| 20609 | | 20609 | |
| 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; |
| 20644 | | 20644 | |
| 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; |
| 20668 | | 20668 | |
| 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; |
| 20692 | | 20692 | |
| 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; |
| 20716 | | 20716 | |
| 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 }; |
| 20779 | | 20779 | |
| 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 }; |
| 20792 | | 20792 | |
| 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 }; |
| 20806 | | 20806 | |
| 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 | } |
| 20830 | | 20830 | |
| 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 | } |
| 20855 | | 20855 | |
| 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); |
| 20858 | | 20858 | |
| 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"); |
| 20882 | | 20882 | |
| 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"); |
| 20885 | | 20885 | |
| 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"); |
| 20888 | | 20888 | |
| 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"); |
| 20891 | | 20891 | |
| 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"); |
| 20948 | | 20948 | |
| 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); |
| 20952 | | 20952 | |
| 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"); |
| 20955 | | 20955 | |
| 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); |
| 20959 | | 20959 | |
| 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"); |
| 20962 | | 20962 | |
| 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 number | 23763 | // 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 | } |
| 23775 | | 23775 | |
| 23776 | // integer widening | 23776 | // 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 | } |
| 23814 | | 23814 | |
| 23815 | // float widening | 23815 | // 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 | }; |
| 26625 | | 26625 | |
| 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 | }; |
| 26721 | | 26721 | |
| 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); |
| 27087 | | 27087 | |
| 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-terminated | 27358 | // 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 | }; |
| 27617 | | 27617 | |
| 27618 | // TODO handle comparisons against lazy zero values | 27618 | // TODO handle comparisons against lazy zero values |
| 27619 | // Some values can be compared against zero without being runtime known or without forcing | 27619 | // 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 to | 27620 | // 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 layout | 27621 | // 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)) orelse | 29277 | 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 location | 29472 | 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; |
| 29476 | | 29476 | |
| 29477 | // This puts the memory into the union arena, not the enum arena, but | 29477 | // 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; |