aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-06-02 15:20:51 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-06-02 15:20:51 -0400
commitb85b68a7fd175169e0f07ab733bde6d5654b1044 (patch)
tree309934a6d7db1864710ac3cdf237431f06bad8b1 /src/ir.cpp
parente514454c0e092794171d4a62260971cc8de6f200 (diff)
downloadzig-b85b68a7fd175169e0f07ab733bde6d5654b1044.tar.gz
zig-b85b68a7fd175169e0f07ab733bde6d5654b1044.zip
better compile error for error sets behind nullable
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index d996b4a2be..5cada29076 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -7934,11 +7934,20 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
return ImplicitCastMatchResultReportedError;
}
+ // implicit conversion from ?T to ?U
+ if (expected_type->id == TypeTableEntryIdMaybe && actual_type->id == TypeTableEntryIdMaybe) {
+ ImplicitCastMatchResult res = ir_types_match_with_implicit_cast(ira, expected_type->data.maybe.child_type,
+ actual_type->data.maybe.child_type, value);
+ if (res != ImplicitCastMatchResultNo)
+ return res;
+ }
+
// implicit conversion from non maybe type to maybe type
- if (expected_type->id == TypeTableEntryIdMaybe &&
- ir_types_match_with_implicit_cast(ira, expected_type->data.maybe.child_type, actual_type, value))
- {
- return ImplicitCastMatchResultYes;
+ if (expected_type->id == TypeTableEntryIdMaybe) {
+ ImplicitCastMatchResult res = ir_types_match_with_implicit_cast(ira, expected_type->data.maybe.child_type,
+ actual_type, value);
+ if (res != ImplicitCastMatchResultNo)
+ return res;
}
// implicit conversion from null literal to maybe type