@@ -1901,7 +1901,6 @@ pub fn resolveConstStringIntern(
pub fn resolveType(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !Type {
const air_inst = try sema.resolveInst(zir_ref);
assert(air_inst != .var_args_param_type);
const ty = try sema.analyzeAsType(block, src, air_inst);
if (ty.isGenericPoison()) return error.GenericPoison;
return ty;
@@ -4572,12 +4571,10 @@ fn zirValidateRefTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
const src = un_tok.src();
// In case of GenericPoison, we don't actually have a type, so this will be
// treated as an untyped address-of operator.
if (un_tok.operand == .var_args_param_type) return;
const operand_air_inst = sema.resolveInst(un_tok.operand) catch |err| switch (err) {
error.GenericPoison => return,
else => |e| return e,
};
if (operand_air_inst == .var_args_param_type) return;
const ty_operand = sema.analyzeAsType(block, src, operand_air_inst) catch |err| switch (err) {
error.GenericPoison => return,
else => |e| return e,
@@ -7363,7 +7360,7 @@ const CallArgsInfo = union(enum) {
}
/// Analyzes the arg at `arg_index` and coerces it to `param_ty`.
/// `param_ty` may be `generic_poison` or `var_args_param`.
/// `param_ty` may be `generic_poison`. A value of `null` indicates a varargs parameter.
/// `func_ty_info` may be the type before instantiation, even if a generic
/// instantiation has been partially completed.
fn analyzeArg(
@@ -7371,16 +7368,16 @@ const CallArgsInfo = union(enum) {
sema: *Sema,
block: *Block,
arg_index: usize,
param_ty: Type,
maybe_param_ty: ?Type,
func_ty_info: InternPool.Key.FuncType,
func_inst: Air.Inst.Ref,
) CompileError!Air.Inst.Ref {
const mod = sema.mod;
const param_count = func_ty_info.param_types.len;
switch (param_ty.toIntern()) {
.generic_poison_type, .var_args_param_type => {},
if (maybe_param_ty) |param_ty| switch (param_ty.toIntern()) {
.generic_poison_type => {},
else => try sema.queueFullTypeResolution(param_ty),
}
};
const uncoerced_arg: Air.Inst.Ref = switch (cai) {
inline .resolved, .call_builtin => |resolved| resolved.args[arg_index],
.zir_call => |zir_call| arg_val: {
@@ -7409,7 +7406,8 @@ const CallArgsInfo = union(enum) {
// TODO set comptime_reason
}
// Give the arg its result type
sema.inst_map.putAssumeCapacity(zir_call.call_inst, Air.internedToRef(param_ty.toIntern()));
const provide_param_ty = if (maybe_param_ty) |t| t else Type.generic_poison;
sema.inst_map.putAssumeCapacity(zir_call.call_inst, Air.internedToRef(provide_param_ty.toIntern()));
// Resolve the arg!
const uncoerced_arg = try sema.resolveInlineBody(block, arg_body, zir_call.call_inst);
@@ -7426,9 +7424,11 @@ const CallArgsInfo = union(enum) {
break :arg_val uncoerced_arg;
},
};
const param_ty = maybe_param_ty orelse {
return sema.coerceVarArgParam(block, uncoerced_arg, cai.argSrc(block, arg_index));
};
switch (param_ty.toIntern()) {
.generic_poison_type => return uncoerced_arg,
.var_args_param_type => return sema.coerceVarArgParam(block, uncoerced_arg, cai.argSrc(block, arg_index)),
else => return sema.coerceExtra(
block,
param_ty,
@@ -7970,10 +7970,10 @@ fn analyzeCall(
const args = try sema.arena.alloc(Air.Inst.Ref, args_info.count());
for (args, 0..) |*arg_out, arg_idx| {
// Non-generic, so param types are already resolved
const param_ty = if (arg_idx < func_ty_info.param_types.len) ty: {
const param_ty: ?Type = if (arg_idx < func_ty_info.param_types.len) ty: {
break :ty Type.fromInterned(func_ty_info.param_types.get(ip)[arg_idx]);
} else Type.fromInterned(InternPool.Index.var_args_param_type);
assert(!param_ty.isGenericPoison());
} else null;
if (param_ty) |t| assert(!t.isGenericPoison());
arg_out.* = try args_info.analyzeArg(sema, block, arg_idx, param_ty, func_ty_info, func);
try sema.validateRuntimeValue(block, args_info.argSrc(block, arg_idx), arg_out.*);
if (sema.typeOf(arg_out.*).zigTypeTag(mod) == .NoReturn) {
@@ -10226,12 +10226,10 @@ fn analyzeAs(
) CompileError!Air.Inst.Ref {
const mod = sema.mod;
const operand = try sema.resolveInst(zir_operand);
if (zir_dest_type == .var_args_param_type) return operand;
const operand_air_inst = sema.resolveInst(zir_dest_type) catch |err| switch (err) {
error.GenericPoison => return operand,
else => |e| return e,
};
if (operand_air_inst == .var_args_param_type) return operand;
const dest_ty = sema.analyzeAsType(block, src, operand_air_inst) catch |err| switch (err) {
error.GenericPoison => return operand,
else => |e| return e,
@@ -35664,8 +35662,6 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!void {
const ty_ip = ty.toIntern();
switch (ty_ip) {
.var_args_param_type => unreachable,
.none => unreachable,
.u0_type,
@@ -37184,7 +37180,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
.empty_struct,
.generic_poison,
// invalid
.var_args_param_type,
.none,
=> unreachable,