| ... | ... | @@ -9219,6 +9219,21 @@ fn finishFunc( |
| 9219 | 9219 | return Air.internedToRef(if (opt_func_index != .none) opt_func_index else func_ty); |
| 9220 | 9220 | } |
| 9221 | 9221 | |
| 9222 | fn genericArgSrcLoc(sema: *Sema, block: *Block, param_index: u32, param_src: LazySrcLoc) Module.SrcLoc { |
| 9223 | const mod = sema.mod; |
| 9224 | if (sema.generic_owner == .none) return param_src.toSrcLoc(mod.declPtr(block.src_decl), mod); |
| 9225 | const arg_decl = sema.generic_call_decl.unwrap().?; |
| 9226 | const arg_src: LazySrcLoc = if (param_index == 0 and sema.generic_bound_arg_src != null) |
| 9227 | sema.generic_bound_arg_src.? |
| 9228 | else |
| 9229 | .{ .call_arg = .{ |
| 9230 | .decl = arg_decl, |
| 9231 | .call_node_offset = sema.generic_call_src.node_offset.x, |
| 9232 | .arg_index = param_index - @intFromBool(sema.generic_bound_arg_src != null), |
| 9233 | } }; |
| 9234 | return arg_src.toSrcLoc(mod.declPtr(arg_decl), mod); |
| 9235 | } |
| 9236 | |
| 9222 | 9237 | fn zirParam( |
| 9223 | 9238 | sema: *Sema, |
| 9224 | 9239 | block: *Block, |
| ... | ... | @@ -9226,7 +9241,6 @@ fn zirParam( |
| 9226 | 9241 | param_index: u32, |
| 9227 | 9242 | comptime_syntax: bool, |
| 9228 | 9243 | ) CompileError!void { |
| 9229 | | const mod = sema.mod; |
| 9230 | 9244 | const gpa = sema.gpa; |
| 9231 | 9245 | const inst_data = sema.code.instructions.items(.data)[inst].pl_tok; |
| 9232 | 9246 | const src = inst_data.src(); |
| ... | ... | @@ -9330,15 +9344,8 @@ fn zirParam( |
| 9330 | 9344 | sema.comptime_args[param_index] = val.toIntern(); |
| 9331 | 9345 | return; |
| 9332 | 9346 | } |
| 9333 | | const arg_src: LazySrcLoc = if (param_index == 0 and sema.generic_bound_arg_src != null) |
| 9334 | | sema.generic_bound_arg_src.? |
| 9335 | | else if (sema.generic_call_src == .node_offset) .{ .call_arg = .{ |
| 9336 | | .decl = sema.generic_call_decl.unwrap().?, |
| 9337 | | .call_node_offset = sema.generic_call_src.node_offset.x, |
| 9338 | | .arg_index = param_index - @intFromBool(sema.generic_bound_arg_src != null), |
| 9339 | | } } else src; |
| 9340 | 9347 | const msg = msg: { |
| 9341 | | const src_loc = arg_src.toSrcLoc(mod.declPtr(block.src_decl), mod); |
| 9348 | const src_loc = sema.genericArgSrcLoc(block, param_index, src); |
| 9342 | 9349 | const msg = try Module.ErrorMsg.create(gpa, src_loc, "{s}", .{ |
| 9343 | 9350 | @as([]const u8, "runtime-known argument passed to comptime parameter"), |
| 9344 | 9351 | }); |
| ... | ... | @@ -9384,7 +9391,6 @@ fn zirParamAnytype( |
| 9384 | 9391 | param_index: u32, |
| 9385 | 9392 | comptime_syntax: bool, |
| 9386 | 9393 | ) CompileError!void { |
| 9387 | | const mod = sema.mod; |
| 9388 | 9394 | const gpa = sema.gpa; |
| 9389 | 9395 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 9390 | 9396 | const param_name: Zir.NullTerminatedString = @enumFromInt(inst_data.start); |
| ... | ... | @@ -9398,13 +9404,6 @@ fn zirParamAnytype( |
| 9398 | 9404 | sema.comptime_args[param_index] = opv.toIntern(); |
| 9399 | 9405 | return; |
| 9400 | 9406 | } |
| 9401 | | const arg_src: LazySrcLoc = if (param_index == 0 and sema.generic_bound_arg_src != null) |
| 9402 | | sema.generic_bound_arg_src.? |
| 9403 | | else if (sema.generic_call_src == .node_offset) .{ .call_arg = .{ |
| 9404 | | .decl = sema.generic_call_decl.unwrap().?, |
| 9405 | | .call_node_offset = sema.generic_call_src.node_offset.x, |
| 9406 | | .arg_index = param_index - @intFromBool(sema.generic_bound_arg_src != null), |
| 9407 | | } } else src; |
| 9408 | 9407 | |
| 9409 | 9408 | if (comptime_syntax) { |
| 9410 | 9409 | if (try sema.resolveMaybeUndefVal(air_ref)) |val| { |
| ... | ... | @@ -9412,7 +9411,7 @@ fn zirParamAnytype( |
| 9412 | 9411 | return; |
| 9413 | 9412 | } |
| 9414 | 9413 | const msg = msg: { |
| 9415 | | const src_loc = arg_src.toSrcLoc(mod.declPtr(block.src_decl), mod); |
| 9414 | const src_loc = sema.genericArgSrcLoc(block, param_index, src); |
| 9416 | 9415 | const msg = try Module.ErrorMsg.create(gpa, src_loc, "{s}", .{ |
| 9417 | 9416 | @as([]const u8, "runtime-known argument passed to comptime parameter"), |
| 9418 | 9417 | }); |
| ... | ... | @@ -9432,7 +9431,7 @@ fn zirParamAnytype( |
| 9432 | 9431 | return; |
| 9433 | 9432 | } |
| 9434 | 9433 | const msg = msg: { |
| 9435 | | const src_loc = arg_src.toSrcLoc(mod.declPtr(block.src_decl), mod); |
| 9434 | const src_loc = sema.genericArgSrcLoc(block, param_index, src); |
| 9436 | 9435 | const msg = try Module.ErrorMsg.create(gpa, src_loc, "{s}", .{ |
| 9437 | 9436 | @as([]const u8, "runtime-known argument passed to comptime-only type parameter"), |
| 9438 | 9437 | }); |