Skip to content

Commit

Permalink
fix Issue 11136 - ICE on incorrect module declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Oct 2, 2013
1 parent e0a201b commit 483ecc2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ void Module::parse()
this->safe = md->safe;
Package *ppack = NULL;
dst = Package::resolve(md->packages, &this->parent, &ppack);
assert(dst);
#if 0
if (ppack && ppack->isModule())
{
Expand Down Expand Up @@ -559,7 +560,7 @@ void Module::parse()
* If both are used in one compilation, 'pkg' as a module (== pkg/package.d)
* and a package name 'pkg' will conflict each other.
*
* To avoid the confliction,
* To avoid the conflict:
* 1. If preceding package name insertion had occurred by Package::resolve,
* later package.d loading will change Package::isPkgMod to PKGmodule and set Package::mod.
* 2. Otherwise, 'package.d' wrapped by 'Package' is inserted to the internal tree in here.
Expand Down Expand Up @@ -688,7 +689,7 @@ void Module::semantic()
// gets imported, it is unaffected by context.
Scope *sc = scope; // see if already got one from importAll()
if (!sc)
{ printf("test2\n");
{
Scope::createGlobal(this); // create root scope
}

Expand Down Expand Up @@ -1121,6 +1122,10 @@ DsymbolTable *Package::resolve(Identifiers *packages, Dsymbol **pparent, Package
// to be checked at a higher level, where a nice error message
// can be generated.
// dot net needs modules and packages with same name

// But we still need a symbol table for it
if (!pkg->symtab)
pkg->symtab = new DsymbolTable();
}
parent = pkg;
dst = pkg->symtab;
Expand Down
1 change: 1 addition & 0 deletions test/compilable/imports/bar11136.d
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module test11136.bar11136;
3 changes: 3 additions & 0 deletions test/compilable/test11136.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// EXTRA_SOURCES: imports/bar11136.d

module test11136;

0 comments on commit 483ecc2

Please sign in to comment.