Skip to content

Commit

Permalink
Merge pull request #4517 from 9rnsr/fix8234
Browse files Browse the repository at this point in the history
Issue 8234 - symbols used in CTFE affect the function literal type
  • Loading branch information
WalterBright committed Mar 27, 2015
2 parents 1139c42 + cd3cd0d commit c420fa1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/declaration.c
Expand Up @@ -1757,8 +1757,9 @@ bool lambdaCheckForNestedRef(Expression *e, Scope *sc);
bool VarDeclaration::checkNestedReference(Scope *sc, Loc loc)
{
//printf("VarDeclaration::checkNestedReference() %s\n", toChars());
if (parent && !isDataseg() && parent != sc->parent &&
!(storage_class & STCmanifest))
if (parent && parent != sc->parent &&
!isDataseg() && !(storage_class & STCmanifest) &&
sc->intypeof != 1 && !(sc->flags & SCOPEctfe))
{
// The function that this variable is in
FuncDeclaration *fdv = toParent()->isFuncDeclaration();
Expand Down
20 changes: 20 additions & 0 deletions test/compilable/testInference.d
Expand Up @@ -238,6 +238,26 @@ pure string escapeShellArguments()
return escapeShellArgument!allocator();
}

/***************************************************/
// 8234

void test8234()
{
immutable int x = 0;

alias FP = typeof({ enum e = x; return e; });
static assert(is(FP : int function()));

auto fp = { enum e = x; return e; };
static assert(is(typeof(fp) : int function()));

alias DG = typeof({ auto e = x; return e; });
static assert(is(DG : int delegate()));

auto dg = { auto e = x; return e; };
static assert(is(typeof(dg) : int delegate()));
}

/***************************************************/
// 8504

Expand Down

0 comments on commit c420fa1

Please sign in to comment.