| ... | @@ -9314,7 +9314,7 @@ fn intCast( | ... | @@ -9314,7 +9314,7 @@ fn intCast( |
| 9314 | break :ok all_in_range; | 9314 | break :ok all_in_range; |
| 9315 | } else ok: { | 9315 | } else ok: { |
| 9316 | const zero_inst = Air.internedToRef((try pt.intValue(operand_ty, 0)).toIntern()); | 9316 | const zero_inst = Air.internedToRef((try pt.intValue(operand_ty, 0)).toIntern()); |
| 9317 | const is_in_range = try block.addBinOp(.cmp_lte, operand, zero_inst); | 9317 | const is_in_range = try block.addBinOp(.cmp_eq, operand, zero_inst); |
| 9318 | break :ok is_in_range; | 9318 | break :ok is_in_range; |
| 9319 | }; | 9319 | }; |
| 9320 | try sema.addSafetyCheck(block, src, ok, .integer_out_of_bounds); | 9320 | try sema.addSafetyCheck(block, src, ok, .integer_out_of_bounds); |
| ... | @@ -12012,15 +12012,12 @@ fn resolveSwitchPayloadCaptureTaggedUnion( | ... | @@ -12012,15 +12012,12 @@ fn resolveSwitchPayloadCaptureTaggedUnion( |
| 12012 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_index]); | 12012 | const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 12013 | const payload_ref: Air.Inst.Ref = payload_ref: { | 12013 | const payload_ref: Air.Inst.Ref = payload_ref: { |
| 12014 | if (capture_by_ref) { | 12014 | if (capture_by_ref) { |
| 12015 | const operand_ptr_info = sema.typeOf(loaded_operand).ptrInfo(zcu); | 12015 | const ptr_field_ty = try sema.typeOf(loaded_operand).fieldPtrType(field_index, pt); |
| 12016 | const ptr_field_ty = try pt.ptrType(.{ | 12016 | if (try sema.resolveDefinedValue(case_block, operand_src, loaded_operand)) |op_ptr_val| { |
| 12017 | .child = field_ty.toIntern(), | 12017 | if (op_ptr_val.isUndef(zcu)) break :payload_ref try pt.undefRef(ptr_field_ty); |
| 12018 | .flags = .{ | 12018 | const field_ptr_val = try op_ptr_val.ptrField(field_index, pt); |
| 12019 | .is_const = operand_ptr_info.flags.is_const, | 12019 | break :payload_ref .fromValue(try pt.getCoerced(field_ptr_val, ptr_field_ty)); |
| 12020 | .is_volatile = operand_ptr_info.flags.is_volatile, | 12020 | } |
| 12021 | .address_space = operand_ptr_info.flags.address_space, | | |
| 12022 | }, | | |
| 12023 | }); | | |
| 12024 | break :payload_ref try case_block.addStructFieldPtr(loaded_operand, field_index, ptr_field_ty); | 12021 | break :payload_ref try case_block.addStructFieldPtr(loaded_operand, field_index, ptr_field_ty); |
| 12025 | } | 12022 | } |
| 12026 | if (try sema.resolveDefinedValue(case_block, operand_src, loaded_operand)) |union_val| { | 12023 | if (try sema.resolveDefinedValue(case_block, operand_src, loaded_operand)) |union_val| { |
| ... | @@ -17548,15 +17545,10 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -17548,15 +17545,10 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr |
| 17548 | const is_cold = sema.branch_hint == .cold; | 17545 | const is_cold = sema.branch_hint == .cold; |
| 17549 | | 17546 | |
| 17550 | const operand_ty = sema.typeOf(operand); | 17547 | const operand_ty = sema.typeOf(operand); |
| 17551 | const ptr_info = operand_ty.ptrInfo(zcu); | 17548 | const res_ty = try pt.ptrType(info: { |
| 17552 | const res_ty = try pt.ptrType(.{ | 17549 | var new = operand_ty.ptrInfo(zcu); |
| 17553 | .child = err_union_ty.errorUnionPayload(zcu).toIntern(), | 17550 | new.child = err_union_ty.errorUnionPayload(zcu).toIntern(); |
| 17554 | .flags = .{ | 17551 | break :info new; |
| 17555 | .is_const = ptr_info.flags.is_const, | | |
| 17556 | .is_volatile = ptr_info.flags.is_volatile, | | |
| 17557 | .is_allowzero = ptr_info.flags.is_allowzero, | | |
| 17558 | .address_space = ptr_info.flags.address_space, | | |
| 17559 | }, | | |
| 17560 | }); | 17552 | }); |
| 17561 | const res_ty_ref = Air.internedToRef(res_ty.toIntern()); | 17553 | const res_ty_ref = Air.internedToRef(res_ty.toIntern()); |
| 17562 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.TryPtr).@"struct".field_names.len + | 17554 | try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.TryPtr).@"struct".field_names.len + |
| ... | @@ -26404,23 +26396,21 @@ fn fieldCallBind( | ... | @@ -26404,23 +26396,21 @@ fn fieldCallBind( |
| 26404 | .@"struct" => { | 26396 | .@"struct" => { |
| 26405 | if (zcu.typeToStruct(concrete_ty)) |struct_type| { | 26397 | if (zcu.typeToStruct(concrete_ty)) |struct_type| { |
| 26406 | const field_index = struct_type.nameIndex(ip, field_name) orelse break :find_field; | 26398 | const field_index = struct_type.nameIndex(ip, field_name) orelse break :find_field; |
| 26407 | const field_ty: Type = .fromInterned(struct_type.field_types.get(ip)[field_index]); | 26399 | return sema.finishFieldCallBind(block, src, ptr_ty, field_index, object_ptr); |
| 26408 | | | |
| 26409 | return sema.finishFieldCallBind(block, src, ptr_ty, field_ty, field_index, object_ptr); | | |
| 26410 | } else if (concrete_ty.isTuple(zcu)) { | 26400 | } else if (concrete_ty.isTuple(zcu)) { |
| 26411 | if (field_name.eqlSlice("len", ip)) { | 26401 | if (field_name.eqlSlice("len", ip)) { |
| 26412 | return .{ .direct = try pt.intRef(.usize, concrete_ty.structFieldCount(zcu)) }; | 26402 | return .{ .direct = try pt.intRef(.usize, concrete_ty.structFieldCount(zcu)) }; |
| 26413 | } | 26403 | } |
| 26414 | if (field_name.toUnsigned(ip)) |field_index| { | 26404 | if (field_name.toUnsigned(ip)) |field_index| { |
| 26415 | if (field_index >= concrete_ty.structFieldCount(zcu)) break :find_field; | 26405 | if (field_index >= concrete_ty.structFieldCount(zcu)) break :find_field; |
| 26416 | return sema.finishFieldCallBind(block, src, ptr_ty, concrete_ty.fieldType(field_index, zcu), field_index, object_ptr); | 26406 | return sema.finishFieldCallBind(block, src, ptr_ty, field_index, object_ptr); |
| 26417 | } | 26407 | } |
| 26418 | } else { | 26408 | } else { |
| 26419 | const max = concrete_ty.structFieldCount(zcu); | 26409 | const max = concrete_ty.structFieldCount(zcu); |
| 26420 | for (0..max) |i_usize| { | 26410 | for (0..max) |i_usize| { |
| 26421 | const i: u32 = @intCast(i_usize); | 26411 | const i: u32 = @intCast(i_usize); |
| 26422 | if (field_name == concrete_ty.structFieldName(i, zcu).unwrap().?) { | 26412 | if (field_name == concrete_ty.structFieldName(i, zcu).unwrap().?) { |
| 26423 | return sema.finishFieldCallBind(block, src, ptr_ty, concrete_ty.fieldType(i, zcu), i, object_ptr); | 26413 | return sema.finishFieldCallBind(block, src, ptr_ty, i, object_ptr); |
| 26424 | } | 26414 | } |
| 26425 | } | 26415 | } |
| 26426 | } | 26416 | } |
| ... | @@ -26536,19 +26526,12 @@ fn finishFieldCallBind( | ... | @@ -26536,19 +26526,12 @@ fn finishFieldCallBind( |
| 26536 | block: *Block, | 26526 | block: *Block, |
| 26537 | src: LazySrcLoc, | 26527 | src: LazySrcLoc, |
| 26538 | ptr_ty: Type, | 26528 | ptr_ty: Type, |
| 26539 | field_ty: Type, | | |
| 26540 | field_index: u32, | 26529 | field_index: u32, |
| 26541 | object_ptr: Air.Inst.Ref, | 26530 | object_ptr: Air.Inst.Ref, |
| 26542 | ) CompileError!ResolvedFieldCallee { | 26531 | ) CompileError!ResolvedFieldCallee { |
| 26543 | const pt = sema.pt; | 26532 | const pt = sema.pt; |
| 26544 | const zcu = pt.zcu; | 26533 | const zcu = pt.zcu; |
| 26545 | const ptr_field_ty = try pt.ptrType(.{ | 26534 | const ptr_field_ty = try ptr_ty.fieldPtrType(field_index, pt); |
| 26546 | .child = field_ty.toIntern(), | | |
| 26547 | .flags = .{ | | |
| 26548 | .is_const = !ptr_ty.ptrIsMutable(zcu), | | |
| 26549 | .address_space = ptr_ty.ptrAddressSpace(zcu), | | |
| 26550 | }, | | |
| 26551 | }); | | |
| 26552 | | 26535 | |
| 26553 | const container_ty = ptr_ty.childType(zcu); | 26536 | const container_ty = ptr_ty.childType(zcu); |
| 26554 | if (container_ty.zigTypeTag(zcu) == .@"struct") { | 26537 | if (container_ty.zigTypeTag(zcu) == .@"struct") { |