Skip to content

Commit

Permalink
fix Issue 11513 - Assertion in module.c
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Nov 14, 2013
1 parent 9d18188 commit 9c4aed7
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 17 deletions.
26 changes: 13 additions & 13 deletions src/module.c
Expand Up @@ -514,7 +514,8 @@ void Module::parse()
DsymbolTable *dst;

if (md)
{ /* A ModuleDeclaration, md, was provided.
{
/* A ModuleDeclaration, md, was provided.
* The ModuleDeclaration sets the packages this module appears in, and
* the name of this module.
*/
Expand All @@ -523,17 +524,17 @@ void Module::parse()
Package *ppack = NULL;
dst = Package::resolve(md->packages, &this->parent, &ppack);
assert(dst);
#if 0
if (ppack && ppack->isModule())

Module *m = ppack ? ppack->isModule() : NULL;
if (m && strcmp(m->srcfile->name->name(), "package.d") != 0)
{
error(loc, "package name '%s' in file %s conflicts with usage as a module name in file %s",
ppack->toChars(), srcname, ppack->isModule()->srcfile->toChars());
dst = modules;
::error(md->loc, "package name '%s' conflicts with usage as a module name in file %s",
ppack->toPrettyChars(), m->srcfile->toChars());
}
#endif
}
else
{ /* The name of the module is set to the source file name.
{
/* The name of the module is set to the source file name.
* There are no packages.
*/
dst = modules; // and so this module goes into global module symbol table
Expand Down Expand Up @@ -580,8 +581,7 @@ void Module::parse()
*/
Dsymbol *prev = dst->lookup(ident);
assert(prev);
Module *mprev = prev->isModule();
if (mprev)
if (Module *mprev = prev->isModule())
{
if (strcmp(srcname, mprev->srcfile->toChars()) == 0)
error(loc, "from file %s must be imported as module '%s'",
Expand All @@ -590,10 +590,8 @@ void Module::parse()
error(loc, "from file %s conflicts with another module %s from file %s",
srcname, mprev->toChars(), mprev->srcfile->toChars());
}
else
else if (Package *pkg = prev->isPackage())
{
Package *pkg = prev->isPackage();
assert(pkg);
if (pkg->isPkgMod == PKGunknown && isPackageMod)
{
/* If the previous inserted Package is not yet determined as package.d,
Expand All @@ -606,6 +604,8 @@ void Module::parse()
error(pkg->loc, "from file %s conflicts with package name %s",
srcname, pkg->toChars());
}
else
assert(global.errors);
}
else
{
Expand Down
1 change: 0 additions & 1 deletion test/compilable/imports/bar11136.d

This file was deleted.

3 changes: 0 additions & 3 deletions test/compilable/test11136.d

This file was deleted.

9 changes: 9 additions & 0 deletions test/fail_compilation/ice11136.d
@@ -0,0 +1,9 @@
// EXTRA_SOURCES: imports/bar11136.d
/*
TEST_OUTPUT:
---
fail_compilation/imports/bar11136.d(1): Error: package name 'ice11136' conflicts with usage as a module name in file fail_compilation/ice11136.d
---
*/

module ice11136;
10 changes: 10 additions & 0 deletions test/fail_compilation/ice11513a.d
@@ -0,0 +1,10 @@
/*
TEST_OUTPUT:
---
fail_compilation/imports/ice11513x.d(1): Error: package name 'ice11513a' conflicts with usage as a module name in file fail_compilation/ice11513a.d
---
*/

module ice11513a;

import imports.ice11513x;
10 changes: 10 additions & 0 deletions test/fail_compilation/ice11513b.d
@@ -0,0 +1,10 @@
/*
TEST_OUTPUT:
---
fail_compilation/imports/ice11513y.d(1): Error: package name 'ice11513b' conflicts with usage as a module name in file fail_compilation/ice11513b.d
---
*/

module ice11513b;

import imports.ice11513y;
1 change: 1 addition & 0 deletions test/fail_compilation/imports/bar11136.d
@@ -0,0 +1 @@
module ice11136.bar11136;
1 change: 1 addition & 0 deletions test/fail_compilation/imports/ice11513x.d
@@ -0,0 +1 @@
module ice11513a.imports;
1 change: 1 addition & 0 deletions test/fail_compilation/imports/ice11513y.d
@@ -0,0 +1 @@
module ice11513b.imports.ice11513y;

0 comments on commit 9c4aed7

Please sign in to comment.