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

[REG2.060] Issue 11220 - XXX__lambda2 cannot access frame of function XXX #2652

Merged
merged 1 commit into from Oct 11, 2013
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: 2 additions & 1 deletion src/func.c
Expand Up @@ -2932,7 +2932,8 @@ int FuncDeclaration::getLevel(Loc loc, Scope *sc, FuncDeclaration *fd)
//printf("\ts = %s, '%s'\n", s->kind(), s->toChars());
FuncDeclaration *thisfd = s->isFuncDeclaration();
if (thisfd)
{ if (!thisfd->isNested() && !thisfd->vthis && !sc->intypeof)
{
if (!thisfd->isNested() && !thisfd->vthis && !sc->intypeof)
goto Lerr;
}
else
Expand Down
8 changes: 6 additions & 2 deletions src/template.c
Expand Up @@ -2604,8 +2604,12 @@ void functionResolve(Match *m, Dsymbol *dstart, Loc loc, Scope *sc,

if (FuncLiteralDeclaration *fld = m->lastf->isFuncLiteralDeclaration())
{
// Inside template constraint, nested reference check doesn't work correctly.
if (!(sc->flags & SCOPEstaticif) && fld->tok == TOKreserved)
if ((sc->flags & SCOPEstaticif) || sc->intypeof)
{
// Inside template constraint, or inside typeof,
// nested reference check doesn't work correctly.
}
else if (fld->tok == TOKreserved)
{
// change to non-nested
fld->tok = TOKfunction;
Expand Down
14 changes: 14 additions & 0 deletions test/runnable/funclit.d
Expand Up @@ -860,6 +860,20 @@ void test11081()
}
}

/***************************************************/
// 11220

int parsePrimaryExp11220(int x)
{
parseAmbig11220!( (parsed){ x += 1; } )();
return 1;
}

typeof(handler(1)) parseAmbig11220(alias handler)()
{
return handler(parsePrimaryExp11220(1));
}

/***************************************************/

int main()
Expand Down