File tree 1 file changed +22
-1
lines changed
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -1830,7 +1830,7 @@ class MatchException : Exception
1830
1830
template canMatch (alias handler, Ts... )
1831
1831
if (Ts.length > 0 )
1832
1832
{
1833
- enum canMatch = is (typeof ((Ts args) => handler(args)));
1833
+ enum canMatch = is (typeof ((ref Ts args) => handler(args)));
1834
1834
}
1835
1835
1836
1836
// /
@@ -2575,6 +2575,27 @@ version (D_Exceptions)
2575
2575
}
2576
2576
}
2577
2577
2578
+ // return ref
2579
+ // issue: https://issues.dlang.org/show_bug.cgi?id=23101
2580
+ @safe unittest
2581
+ {
2582
+ static assert (! __traits(compiles, () {
2583
+ SumType! (int , string ) st;
2584
+ return st.match! (
2585
+ function int * (string x) => assert (0 ),
2586
+ function int * (return ref int i) => &i,
2587
+ );
2588
+ }));
2589
+
2590
+ SumType! (int , string ) st;
2591
+ static assert (__traits(compiles, () {
2592
+ return st.match! (
2593
+ function int * (string x) => null ,
2594
+ function int * (return ref int i) => &i,
2595
+ );
2596
+ }));
2597
+ }
2598
+
2578
2599
private void destroyIfOwner (T)(ref T value)
2579
2600
{
2580
2601
static if (hasElaborateDestructor! T)
You can’t perform that action at this time.
0 commit comments