| ... | ... | @@ -1901,7 +1901,6 @@ pub fn resolveConstStringIntern( |
| 1901 | 1901 | |
| 1902 | 1902 | pub fn resolveType(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !Type { |
| 1903 | 1903 | const air_inst = try sema.resolveInst(zir_ref); |
| 1904 | | assert(air_inst != .var_args_param_type); |
| 1905 | 1904 | const ty = try sema.analyzeAsType(block, src, air_inst); |
| 1906 | 1905 | if (ty.isGenericPoison()) return error.GenericPoison; |
| 1907 | 1906 | return ty; |
| ... | ... | @@ -4572,12 +4571,10 @@ fn zirValidateRefTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 4572 | 4571 | const src = un_tok.src(); |
| 4573 | 4572 | // In case of GenericPoison, we don't actually have a type, so this will be |
| 4574 | 4573 | // treated as an untyped address-of operator. |
| 4575 | | if (un_tok.operand == .var_args_param_type) return; |
| 4576 | 4574 | const operand_air_inst = sema.resolveInst(un_tok.operand) catch |err| switch (err) { |
| 4577 | 4575 | error.GenericPoison => return, |
| 4578 | 4576 | else => |e| return e, |
| 4579 | 4577 | }; |
| 4580 | | if (operand_air_inst == .var_args_param_type) return; |
| 4581 | 4578 | const ty_operand = sema.analyzeAsType(block, src, operand_air_inst) catch |err| switch (err) { |
| 4582 | 4579 | error.GenericPoison => return, |
| 4583 | 4580 | else => |e| return e, |
| ... | ... | @@ -7363,7 +7360,7 @@ const CallArgsInfo = union(enum) { |
| 7363 | 7360 | } |
| 7364 | 7361 | |
| 7365 | 7362 | /// Analyzes the arg at `arg_index` and coerces it to `param_ty`. |
| 7366 | | /// `param_ty` may be `generic_poison` or `var_args_param`. |
| 7363 | /// `param_ty` may be `generic_poison`. A value of `null` indicates a varargs parameter. |
| 7367 | 7364 | /// `func_ty_info` may be the type before instantiation, even if a generic |
| 7368 | 7365 | /// instantiation has been partially completed. |
| 7369 | 7366 | fn analyzeArg( |
| ... | ... | @@ -7371,16 +7368,16 @@ const CallArgsInfo = union(enum) { |
| 7371 | 7368 | sema: *Sema, |
| 7372 | 7369 | block: *Block, |
| 7373 | 7370 | arg_index: usize, |
| 7374 | | param_ty: Type, |
| 7371 | maybe_param_ty: ?Type, |
| 7375 | 7372 | func_ty_info: InternPool.Key.FuncType, |
| 7376 | 7373 | func_inst: Air.Inst.Ref, |
| 7377 | 7374 | ) CompileError!Air.Inst.Ref { |
| 7378 | 7375 | const mod = sema.mod; |
| 7379 | 7376 | const param_count = func_ty_info.param_types.len; |
| 7380 | | switch (param_ty.toIntern()) { |
| 7381 | | .generic_poison_type, .var_args_param_type => {}, |
| 7377 | if (maybe_param_ty) |param_ty| switch (param_ty.toIntern()) { |
| 7378 | .generic_poison_type => {}, |
| 7382 | 7379 | else => try sema.queueFullTypeResolution(param_ty), |
| 7383 | | } |
| 7380 | }; |
| 7384 | 7381 | const uncoerced_arg: Air.Inst.Ref = switch (cai) { |
| 7385 | 7382 | inline .resolved, .call_builtin => |resolved| resolved.args[arg_index], |
| 7386 | 7383 | .zir_call => |zir_call| arg_val: { |
| ... | ... | @@ -7409,7 +7406,8 @@ const CallArgsInfo = union(enum) { |
| 7409 | 7406 | // TODO set comptime_reason |
| 7410 | 7407 | } |
| 7411 | 7408 | // Give the arg its result type |
| 7412 | | sema.inst_map.putAssumeCapacity(zir_call.call_inst, Air.internedToRef(param_ty.toIntern())); |
| 7409 | const provide_param_ty = if (maybe_param_ty) |t| t else Type.generic_poison; |
| 7410 | sema.inst_map.putAssumeCapacity(zir_call.call_inst, Air.internedToRef(provide_param_ty.toIntern())); |
| 7413 | 7411 | // Resolve the arg! |
| 7414 | 7412 | const uncoerced_arg = try sema.resolveInlineBody(block, arg_body, zir_call.call_inst); |
| 7415 | 7413 | |
| ... | ... | @@ -7426,9 +7424,11 @@ const CallArgsInfo = union(enum) { |
| 7426 | 7424 | break :arg_val uncoerced_arg; |
| 7427 | 7425 | }, |
| 7428 | 7426 | }; |
| 7427 | const param_ty = maybe_param_ty orelse { |
| 7428 | return sema.coerceVarArgParam(block, uncoerced_arg, cai.argSrc(block, arg_index)); |
| 7429 | }; |
| 7429 | 7430 | switch (param_ty.toIntern()) { |
| 7430 | 7431 | .generic_poison_type => return uncoerced_arg, |
| 7431 | | .var_args_param_type => return sema.coerceVarArgParam(block, uncoerced_arg, cai.argSrc(block, arg_index)), |
| 7432 | 7432 | else => return sema.coerceExtra( |
| 7433 | 7433 | block, |
| 7434 | 7434 | param_ty, |
| ... | ... | @@ -7970,10 +7970,10 @@ fn analyzeCall( |
| 7970 | 7970 | const args = try sema.arena.alloc(Air.Inst.Ref, args_info.count()); |
| 7971 | 7971 | for (args, 0..) |*arg_out, arg_idx| { |
| 7972 | 7972 | // Non-generic, so param types are already resolved |
| 7973 | | const param_ty = if (arg_idx < func_ty_info.param_types.len) ty: { |
| 7973 | const param_ty: ?Type = if (arg_idx < func_ty_info.param_types.len) ty: { |
| 7974 | 7974 | break :ty Type.fromInterned(func_ty_info.param_types.get(ip)[arg_idx]); |
| 7975 | | } else Type.fromInterned(InternPool.Index.var_args_param_type); |
| 7976 | | assert(!param_ty.isGenericPoison()); |
| 7975 | } else null; |
| 7976 | if (param_ty) |t| assert(!t.isGenericPoison()); |
| 7977 | 7977 | arg_out.* = try args_info.analyzeArg(sema, block, arg_idx, param_ty, func_ty_info, func); |
| 7978 | 7978 | try sema.validateRuntimeValue(block, args_info.argSrc(block, arg_idx), arg_out.*); |
| 7979 | 7979 | if (sema.typeOf(arg_out.*).zigTypeTag(mod) == .NoReturn) { |
| ... | ... | @@ -10226,12 +10226,10 @@ fn analyzeAs( |
| 10226 | 10226 | ) CompileError!Air.Inst.Ref { |
| 10227 | 10227 | const mod = sema.mod; |
| 10228 | 10228 | const operand = try sema.resolveInst(zir_operand); |
| 10229 | | if (zir_dest_type == .var_args_param_type) return operand; |
| 10230 | 10229 | const operand_air_inst = sema.resolveInst(zir_dest_type) catch |err| switch (err) { |
| 10231 | 10230 | error.GenericPoison => return operand, |
| 10232 | 10231 | else => |e| return e, |
| 10233 | 10232 | }; |
| 10234 | | if (operand_air_inst == .var_args_param_type) return operand; |
| 10235 | 10233 | const dest_ty = sema.analyzeAsType(block, src, operand_air_inst) catch |err| switch (err) { |
| 10236 | 10234 | error.GenericPoison => return operand, |
| 10237 | 10235 | else => |e| return e, |
| ... | ... | @@ -35664,8 +35662,6 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!void { |
| 35664 | 35662 | const ty_ip = ty.toIntern(); |
| 35665 | 35663 | |
| 35666 | 35664 | switch (ty_ip) { |
| 35667 | | .var_args_param_type => unreachable, |
| 35668 | | |
| 35669 | 35665 | .none => unreachable, |
| 35670 | 35666 | |
| 35671 | 35667 | .u0_type, |
| ... | ... | @@ -37184,7 +37180,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 37184 | 37180 | .empty_struct, |
| 37185 | 37181 | .generic_poison, |
| 37186 | 37182 | // invalid |
| 37187 | | .var_args_param_type, |
| 37188 | 37183 | .none, |
| 37189 | 37184 | => unreachable, |
| 37190 | 37185 | |