mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-05 17:43:35 +03:00
Fixed lambda inference
This commit is contained in:
parent
925303e334
commit
eba8aac824
3 changed files with 17 additions and 6 deletions
|
@ -5197,6 +5197,11 @@ Expression *FuncExp::inferType(Scope *sc, Type *to)
|
||||||
sc = scope;
|
sc = scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if IN_LLVM
|
||||||
|
if (fd->tok == TOKreserved && to->ty == Tpointer && to->nextOf()->ty == Tfunction)
|
||||||
|
fd->tok = TOKfunction;
|
||||||
|
#endif
|
||||||
|
|
||||||
Expression *e = NULL;
|
Expression *e = NULL;
|
||||||
if (td)
|
if (td)
|
||||||
{ /// Parameter types inference from
|
{ /// Parameter types inference from
|
||||||
|
|
|
@ -5306,6 +5306,15 @@ void TypeFunction::toDecoBuffer(OutBuffer *buf, int flag, bool mangle)
|
||||||
buf->writeByte('M');
|
buf->writeByte('M');
|
||||||
ad->type->toDecoBuffer(buf, 0, false);
|
ad->type->toDecoBuffer(buf, 0, false);
|
||||||
}
|
}
|
||||||
|
if (FuncLiteralDeclaration *literal = funcdecl->isFuncLiteralDeclaration()) {
|
||||||
|
// Never merge types of function literals of different kind
|
||||||
|
if (literal->tok == TOKreserved)
|
||||||
|
buf->writeByte('L');
|
||||||
|
else if (literal->tok == TOKfunction)
|
||||||
|
buf->writeByte('F');
|
||||||
|
else if (literal->tok == TOKdelegate)
|
||||||
|
buf->writeByte('D');
|
||||||
|
}
|
||||||
/* BUG This causes problems with delegate types
|
/* BUG This causes problems with delegate types
|
||||||
On the other hand, the llvm type for nested functions *is* different
|
On the other hand, the llvm type for nested functions *is* different
|
||||||
so not doing anything here may be lead to bugs!
|
so not doing anything here may be lead to bugs!
|
||||||
|
|
|
@ -2636,10 +2636,7 @@ DValue* FuncExp::toElem(IRState* p)
|
||||||
fd->codegen(Type::sir);
|
fd->codegen(Type::sir);
|
||||||
assert(fd->ir.irFunc->func);
|
assert(fd->ir.irFunc->func);
|
||||||
|
|
||||||
if (fd->tok == TOKreserved && type->ty == Tpointer && fd->vthis)
|
if(fd->isNested() && !(fd->tok == TOKreserved && type->ty == Tpointer && fd->vthis)) {
|
||||||
fd->tok = TOKfunction;
|
|
||||||
|
|
||||||
if(fd->isNested()) {
|
|
||||||
LLType* dgty = DtoType(type);
|
LLType* dgty = DtoType(type);
|
||||||
|
|
||||||
LLValue* cval;
|
LLValue* cval;
|
||||||
|
@ -2689,9 +2686,9 @@ LLConstant* FuncExp::toConstElem(IRState* p)
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
assert(fd);
|
assert(fd);
|
||||||
if (fd->tok != TOKfunction)
|
if (fd->tok != TOKfunction && !(fd->tok == TOKreserved && type->ty == Tpointer && fd->vthis))
|
||||||
{
|
{
|
||||||
assert(fd->tok == TOKdelegate);
|
assert(fd->tok == TOKdelegate || fd->tok == TOKreserved);
|
||||||
error("delegate literals as constant expressions are not yet allowed");
|
error("delegate literals as constant expressions are not yet allowed");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue