Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue 19523 - "undefined identifier" causes DMD crash #9360

Merged
merged 1 commit into from Feb 14, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/dmd/expression.d
Expand Up @@ -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,
Expand Down
19 changes: 19 additions & 0 deletions 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_)`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should _error_ really appear in the user-facing output?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say ideally not.

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) {}