diff --git a/compiler/src/dmd/typesem.d b/compiler/src/dmd/typesem.d index a909fcf14c18..3933d7dfddbb 100644 --- a/compiler/src/dmd/typesem.d +++ b/compiler/src/dmd/typesem.d @@ -835,7 +835,9 @@ extern (D) MATCH callMatch(TypeFunction tf, Type tthis, ArgumentList argumentLis L1: if (parameterList.varargs == VarArg.typesafe && u + 1 == nparams) // if last varargs param { - auto trailingArgs = args[u .. $]; + Expression[] trailingArgs; + if (args.length >= u) + trailingArgs = args[u .. $]; if (auto vmatch = matchTypeSafeVarArgs(tf, p, trailingArgs, pMessage)) return vmatch < match ? vmatch : match; // Error message was already generated in `matchTypeSafeVarArgs` diff --git a/compiler/test/compilable/test24760.d b/compiler/test/compilable/test24760.d new file mode 100644 index 000000000000..7c84848a6fe9 --- /dev/null +++ b/compiler/test/compilable/test24760.d @@ -0,0 +1,4 @@ +// https://issues.dlang.org/show_bug.cgi?id=24760 + +long f(int e = 0, uint[] optional...) => optional.length; +long f0() => f(); // compiler segfaults