Skip to content

Commit

Permalink
Merge pull request #6128 from MartinNowak/fix16460
Browse files Browse the repository at this point in the history
fix Issue 16460 - ICE for package visibility check in function literal
  • Loading branch information
WalterBright committed Sep 13, 2016
2 parents 6b28536 + 0c9374c commit 8679fd9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/func.d
Expand Up @@ -1397,7 +1397,15 @@ public:
localsymtab = new DsymbolTable();
// Establish function scope
auto ss = new ScopeDsymbol();
ss.parent = sc.scopesym;
// find enclosing scope symbol, might skip symbol-less CTFE and/or FuncExp scopes
for (auto scx = sc; ; scx = scx.enclosing)
{
if (scx.scopesym)
{
ss.parent = scx.scopesym;
break;
}
}
Scope* sc2 = sc.push(ss);
sc2.func = this;
sc2.parent = this;
Expand Down
3 changes: 3 additions & 0 deletions test/compilable/imports/imp16460.d
@@ -0,0 +1,3 @@
module imports.imp16460;

package enum val = 0;
13 changes: 13 additions & 0 deletions test/compilable/test16460.d
@@ -0,0 +1,13 @@
module imports.test16460;

void bug()
{
auto d1 = (){
import imports.imp16460;
return val;
};
enum d2 = (){
import imports.imp16460;
return val;
};
}

0 comments on commit 8679fd9

Please sign in to comment.