mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
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:
commit
cb4fb0ac57
2 changed files with 21 additions and 3 deletions
|
@ -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 ||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue