Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@ jobs:
- macOS-latest
dc:
- dmd-latest
- dmd-2.099.1
- dmd-2.098.1
- dmd-2.101.2
- ldc-latest
- ldc-1.29.0
- ldc-1.28.1
- ldc-1.31.0
exclude:
# macOS requires DMD >= 2.107.1
- os: macOS-latest
dc: dmd-2.099.1
- os: macOS-latest
dc: dmd-2.098.1
dc: dmd-2.101.2
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"license": "BSL-1.0",

"toolchainRequirements": {
"frontend": ">=2.098"
"frontend": ">=2.101"
},

"dflags": ["-preview=fieldwise"],
Expand Down
16 changes: 15 additions & 1 deletion src/sumtype.d
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@ class MatchException : Exception
template canMatch(alias handler, Ts...)
if (Ts.length > 0)
{
enum canMatch = is(typeof((ref Ts args) => handler(args)));
enum canMatch = is(typeof(auto ref (ref Ts args) => handler(args)));
}

///
Expand All @@ -1752,6 +1752,20 @@ template canMatch(alias handler, Ts...)
assert(canMatch!(OverloadSet.fun, double));
}

// Allows returning non-copyable types by ref
// https://github.com/dlang/phobos/issues/10647
@safe unittest {
static struct NoCopy
{
@disable this(this);
}

static NoCopy lvalue;
static ref handler(int _) => lvalue;

assert(canMatch!(handler, int));
}

// Like aliasSeqOf!(iota(n)), but works in BetterC
private template Iota(size_t n)
{
Expand Down