File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -1830,7 +1830,7 @@ class MatchException : Exception
18301830template canMatch (alias handler, Ts... )
18311831if (Ts.length > 0 )
18321832{
1833- enum canMatch = is (typeof ((ref Ts args) => handler(args)));
1833+ enum canMatch = is (typeof (auto ref (ref Ts args) => handler(args)));
18341834}
18351835
18361836// /
@@ -1855,6 +1855,21 @@ if (Ts.length > 0)
18551855 assert (canMatch! (OverloadSet.fun, double ));
18561856}
18571857
1858+ // Allows returning non-copyable types by ref
1859+ // https://github.com/dlang/phobos/issues/10647
1860+ @safe unittest
1861+ {
1862+ static struct NoCopy
1863+ {
1864+ @disable this (this );
1865+ }
1866+
1867+ static NoCopy lvalue;
1868+ static ref handler (int _) => lvalue;
1869+
1870+ assert (canMatch! (handler, int ));
1871+ }
1872+
18581873// Like aliasSeqOf!(iota(n)), but works in BetterC
18591874private template Iota (size_t n)
18601875{
You can’t perform that action at this time.
0 commit comments