| ... | ... | @@ -4739,7 +4739,8 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn, arena: Allocator) Sem |
| 4739 | 4739 | // map the comptime parameters to constant values and only emit arg AIR instructions |
| 4740 | 4740 | // for the runtime ones. |
| 4741 | 4741 | const fn_ty = decl.ty; |
| 4742 | | const runtime_params_len = @intCast(u32, fn_ty.fnParamLen()); |
| 4742 | const fn_ty_info = fn_ty.fnInfo(); |
| 4743 | const runtime_params_len = @intCast(u32, fn_ty_info.param_types.len); |
| 4743 | 4744 | try inner_block.instructions.ensureTotalCapacityPrecise(gpa, runtime_params_len); |
| 4744 | 4745 | try sema.air_instructions.ensureUnusedCapacity(gpa, fn_info.total_params_len * 2); // * 2 for the `addType` |
| 4745 | 4746 | try sema.inst_map.ensureUnusedCapacity(gpa, fn_info.total_params_len); |
| ... | ... | @@ -4771,7 +4772,7 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn, arena: Allocator) Sem |
| 4771 | 4772 | continue; |
| 4772 | 4773 | } |
| 4773 | 4774 | } |
| 4774 | | const param_type = fn_ty.fnParamType(runtime_param_index); |
| 4775 | const param_type = fn_ty_info.param_types[runtime_param_index]; |
| 4775 | 4776 | const opt_opv = sema.typeHasOnePossibleValue(&inner_block, param.src, param_type) catch |err| switch (err) { |
| 4776 | 4777 | error.NeededSourceLocation => unreachable, |
| 4777 | 4778 | error.GenericPoison => unreachable, |
| ... | ... | @@ -4822,6 +4823,18 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn, arena: Allocator) Sem |
| 4822 | 4823 | func.state = .success; |
| 4823 | 4824 | log.debug("set {s} to success", .{decl.name}); |
| 4824 | 4825 | |
| 4826 | // Finally we must resolve the return type and parameter types so that backends |
| 4827 | // have full access to type information. |
| 4828 | const src: LazySrcLoc = .{ .node_offset = 0 }; |
| 4829 | sema.resolveFnTypes(&inner_block, src, fn_ty_info) catch |err| switch (err) { |
| 4830 | error.NeededSourceLocation => unreachable, |
| 4831 | error.GenericPoison => unreachable, |
| 4832 | error.ComptimeReturn => unreachable, |
| 4833 | error.ComptimeBreak => unreachable, |
| 4834 | error.AnalysisFail => {}, |
| 4835 | else => |e| return e, |
| 4836 | }; |
| 4837 | |
| 4825 | 4838 | return Air{ |
| 4826 | 4839 | .instructions = sema.air_instructions.toOwnedSlice(), |
| 4827 | 4840 | .extra = sema.air_extra.toOwnedSlice(gpa), |