Skip to content

Commit

Permalink
merge D2 pull #176
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Mar 22, 2012
1 parent bd61df4 commit b324890
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
14 changes: 12 additions & 2 deletions src/import.c
Expand Up @@ -74,7 +74,16 @@ void Import::load(Scope *sc)

// See if existing module
DsymbolTable *dst = Package::resolve(packages, NULL, &pkg);

#if TARGET_NET //dot net needs modules and packages with same name
#else
if (pkg && pkg->isModule())
{
::error(loc, "can only import from a module, not from a member of module %s. Did you mean `import %s : %s`?",
pkg->toChars(), pkg->toChars(), id->toChars());
mod = pkg->isModule(); // Error recovery - treat as import of that module
return;
}
#endif
Dsymbol *s = dst->lookup(id);
if (s)
{
Expand All @@ -84,7 +93,8 @@ void Import::load(Scope *sc)
if (s->isModule())
mod = (Module *)s;
else
error("package and module have the same name");
::error(loc, "can only import from a module, not from package %s.%s",
pkg->toChars(), id->toChars());
#endif
}

Expand Down
14 changes: 5 additions & 9 deletions src/module.c
@@ -1,6 +1,6 @@

// Compiler implementation of the D programming language
// Copyright (c) 1999-2011 by Digital Mars
// Copyright (c) 1999-2012 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
Expand Down Expand Up @@ -1161,14 +1161,10 @@ DsymbolTable *Package::resolve(Identifiers *packages, Dsymbol **pparent, Package
else
{
assert(p->isPackage());
#if TARGET_NET //dot net needs modules and packages with same name
#else
if (p->isModule())
{ p->error("module and package have the same name");
fatal();
break;
}
#endif
// It might already be a module, not a package, but that needs
// to be checked at a higher level, where a nice error message
// can be generated.
// dot net needs modules and packages with same name
}
parent = p;
dst = ((Package *)p)->symtab;
Expand Down

0 comments on commit b324890

Please sign in to comment.