Merge pull request #10513 from MoonlightSentinel/checkaction-lambda

Issue 20331 - checkaction=context segfaults when calling function lit…
merged-on-behalf-of: Petar Kirov <PetarKirov@users.noreply.github.com>
This commit is contained in:
The Dlang Bot 2019-11-02 08:22:18 +01:00 committed by GitHub
commit cb4fb0ac57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View file

@ -5789,9 +5789,16 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
if (tok == TOK.call)
{
const callExp = cast(CallExp) exp.e1;
const callExpIdent = callExp.f.ident;
isEqualsCallExpression = callExpIdent == Id.__equals ||
callExpIdent == Id.eq;
// https://issues.dlang.org/show_bug.cgi?id=20331
// callExp.f may be null if the assert contains a call to
// a function pointer or literal
if (const callExpFunc = callExp.f)
{
const callExpIdent = callExpFunc.ident;
isEqualsCallExpression = callExpIdent == Id.__equals ||
callExpIdent == Id.eq;
}
}
if (tok == TOK.equal || tok == TOK.notEqual ||
tok == TOK.lessThan || tok == TOK.greaterThan ||

View file

@ -21,7 +21,18 @@ void testClass() {
assert(t1 == t1);
}
// https://issues.dlang.org/show_bug.cgi?id=20331
void testAnonymousFunction()
{
bool function() check = () => true;
assert(check());
bool result = true;
assert((() => result)());
}
void main() {
testStruct();
testClass();
testAnonymousFunction();
}