@@ -50,6 +50,8 @@ $(SPEC_S Deprecated Features,
50
50
$(TROW $(DEPLINK .size property), ?, 0.107, 0.107, 2.061 )
51
51
$(TROW $(DEPLINK .typeinfo property), ?, 0.093, 2.061, 2.067 )
52
52
$(TROW $(DEPLINK unannotated asm blocks), ,  , 2.100, (never) )
53
+ $(TROW $(DEPLINK Throwing qualified objects), , 2.104,  , (never) )
54
+ $(TROW $(DEPLINK Catching immutable/inout/shared objects), , 2.106,  , (never) )
53
55
)
54
56
55
57
$(DL
@@ -1022,6 +1024,41 @@ $(H4 Rationale)
1022
1024
interfaces.)
1023
1025
)
1024
1026
1027
+ $(H3 $(DEPNAME Throwing qualified objects))
1028
+
1029
+ $(P
1030
+ Previously, an `immutable`, `const`, `inout` or `shared` exception could be
1031
+ thrown and then caught in an unqualified `catch (Exception e)` clause.
1032
+ That breaks type safety.
1033
+ Throwing a qualified object is now deprecated. This helps to prevent
1034
+ possible mutation of an immutable object in a `catch` clause.
1035
+ )
1036
+
1037
+ $(P
1038
+ The runtime also modifies a thrown object (e.g. to contain a stack
1039
+ trace) which can violate `const` or `immutable` objects. Throwing
1040
+ qualified objects has been deprecated for this reason also.
1041
+ )
1042
+
1043
+ $(H3 $(DEPNAME Catching immutable/inout/shared objects))
1044
+
1045
+ $(P
1046
+ It is unsafe to catch an exception as `immutable`, `inout` or `shared`.
1047
+ This is because the exception may still be accessible through another
1048
+ mutable or non-shared reference.
1049
+ )
1050
+
1051
+ ---
1052
+ auto e = new Exception("first");
1053
+ try {
1054
+ throw e;
1055
+ } catch(immutable Exception ie) { // unsafe
1056
+ e.msg = "second";
1057
+ assert(ie.msg == "first"); // would fail
1058
+ }
1059
+ ---
1060
+
1061
+
1025
1062
Macros:
1026
1063
DEPLINK=$(RELATIVE_LINK2 $0, $0)
1027
1064
DEPLINK2=$(LINK2 $1.html#$2, $2)
0 commit comments