diff --git a/src/dmd/expression.d b/src/dmd/expression.d index 37e090f8b17b..f9d68ca498bb 100644 --- a/src/dmd/expression.d +++ b/src/dmd/expression.d @@ -3694,6 +3694,9 @@ extern (C++) final class FuncExp : Expression TypeFunction tfx = cast(TypeFunction)fd.type; bool convertMatch = (type.ty != to.ty); + if (tfx.ty == Terror) + return MATCH.nomatch; + if (fd.inferRetType && tfx.next.implicitConvTo(tof.next) == MATCH.convert) { /* If return type is inferred and covariant return, diff --git a/test/fail_compilation/b19523.d b/test/fail_compilation/b19523.d new file mode 100644 index 000000000000..9785fdf94bd1 --- /dev/null +++ b/test/fail_compilation/b19523.d @@ -0,0 +1,19 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/b19523.d(12): Error: undefined identifier `SomeStruct` +fail_compilation/b19523.d(13): Error: function `b19523.foo(int delegate() arg)` is not callable using argument types `(_error_)` +fail_compilation/b19523.d(13): cannot pass argument `__lambda1` of type `_error_` to parameter `int delegate() arg` +--- +*/ +module b19523; + +void bar () { + SomeStruct s; + foo({ + return s; + }); +} + +void foo (int delegate() arg) {} +