| author | |
| committer | |
| log | 1a0081b763d145de8a89ab94aca400daa5666dac |
| tree | 8899983ac5f34d8b47b5e31caa6c311e9c773100 |
| parent | e0b635e825b72e1308dd0e2bbee578dafe62d9dc |
See #3342 files changed, 21 insertions(+), 1 deletions(-)
src/ir.cpp+9| ... | ... | @@ -6120,6 +6120,15 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod |
| 6120 | 6120 | { |
| 6121 | 6121 | prev_inst = cur_inst; |
| 6122 | 6122 | continue; |
| 6123 | } else if (prev_type->id == TypeTableEntryIdMaybe && | |
| 6124 | types_match_const_cast_only(prev_type->data.maybe.child_type, cur_type)) | |
| 6125 | { | |
| 6126 | continue; | |
| 6127 | } else if (cur_type->id == TypeTableEntryIdMaybe && | |
| 6128 | types_match_const_cast_only(cur_type->data.maybe.child_type, prev_type)) | |
| 6129 | { | |
| 6130 | prev_inst = cur_inst; | |
| 6131 | continue; | |
| 6123 | 6132 | } else if (prev_type->id == TypeTableEntryIdNumLitInt || |
| 6124 | 6133 | prev_type->id == TypeTableEntryIdNumLitFloat) |
| 6125 | 6134 | { |
test/cases/cast.zig+12-1| ... | ... | @@ -116,4 +116,15 @@ fn returnNullFromMaybeTypeErrorRef() -> %?&A { |
| 116 | 116 | } |
| 117 | 117 | fn returnNullLitFromMaybeTypeErrorRef() -> %?&A { |
| 118 | 118 | return null; |
| 119 | } | |
| \ No newline at end of file | ||
| 119 | } | |
| 120 | ||
| 121 | test "peer type resolution: ?T and T" { | |
| 122 | assert(??peerTypeTAndMaybeT(true, false) == 0); | |
| 123 | } | |
| 124 | fn peerTypeTAndMaybeT(c: bool, b: bool) -> ?usize { | |
| 125 | if (c) { | |
| 126 | return if (b) null else usize(0); | |
| 127 | } | |
| 128 | ||
| 129 | return usize(3); | |
| 130 | } |