| ... | @@ -5337,11 +5337,15 @@ fn analyzeOptionalPayloadPtr( | ... | @@ -5337,11 +5337,15 @@ fn analyzeOptionalPayloadPtr( |
| 5337 | }); | 5337 | }); |
| 5338 | | 5338 | |
| 5339 | if (try sema.resolveDefinedValue(block, src, optional_ptr)) |pointer_val| { | 5339 | if (try sema.resolveDefinedValue(block, src, optional_ptr)) |pointer_val| { |
| | 5340 | if (initializing) { |
| | 5341 | return sema.addConstant( |
| | 5342 | child_pointer, |
| | 5343 | try Value.Tag.opt_payload_ptr.create(sema.arena, pointer_val), |
| | 5344 | ); |
| | 5345 | } |
| 5340 | if (try sema.pointerDeref(block, src, pointer_val, optional_ptr_ty)) |val| { | 5346 | if (try sema.pointerDeref(block, src, pointer_val, optional_ptr_ty)) |val| { |
| 5341 | if (!initializing) { | 5347 | if (val.isNull()) { |
| 5342 | if (val.isNull()) { | 5348 | return sema.fail(block, src, "unable to unwrap null", .{}); |
| 5343 | return sema.fail(block, src, "unable to unwrap null", .{}); | | |
| 5344 | } | | |
| 5345 | } | 5349 | } |
| 5346 | // The same Value represents the pointer to the optional and the payload. | 5350 | // The same Value represents the pointer to the optional and the payload. |
| 5347 | return sema.addConstant( | 5351 | return sema.addConstant( |
| ... | @@ -5488,11 +5492,15 @@ fn analyzeErrUnionPayloadPtr( | ... | @@ -5488,11 +5492,15 @@ fn analyzeErrUnionPayloadPtr( |
| 5488 | }); | 5492 | }); |
| 5489 | | 5493 | |
| 5490 | if (try sema.resolveDefinedValue(block, src, operand)) |pointer_val| { | 5494 | if (try sema.resolveDefinedValue(block, src, operand)) |pointer_val| { |
| | 5495 | if (initializing) { |
| | 5496 | return sema.addConstant( |
| | 5497 | operand_pointer_ty, |
| | 5498 | try Value.Tag.eu_payload_ptr.create(sema.arena, pointer_val), |
| | 5499 | ); |
| | 5500 | } |
| 5491 | if (try sema.pointerDeref(block, src, pointer_val, operand_ty)) |val| { | 5501 | if (try sema.pointerDeref(block, src, pointer_val, operand_ty)) |val| { |
| 5492 | if (!initializing) { | 5502 | if (val.getError()) |name| { |
| 5493 | if (val.getError()) |name| { | 5503 | return sema.fail(block, src, "caught unexpected error '{s}'", .{name}); |
| 5494 | return sema.fail(block, src, "caught unexpected error '{s}'", .{name}); | | |
| 5495 | } | | |
| 5496 | } | 5504 | } |
| 5497 | | 5505 | |
| 5498 | return sema.addConstant( | 5506 | return sema.addConstant( |