Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge upstream stable (e274c8cbcc) #3326

Merged
merged 1 commit into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion dmd/dimport.d
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,16 @@ extern (C++) final class Import : Dsymbol
if (mod && !mod.importedFrom)
mod.importedFrom = sc ? sc._module.importedFrom : Module.rootModule;
if (!pkg)
pkg = mod;
{
if (mod && mod.isPackageFile)
{
// one level depth package.d file (import pkg; ./pkg/package.d)
// it's necessary to use the wrapping Package already created
pkg = mod.pkg;
}
else
pkg = mod;
}
//printf("-Import::load('%s'), pkg = %p\n", toChars(), pkg);
return global.errors != errors;
}
Expand Down
32 changes: 19 additions & 13 deletions dmd/dmodule.d
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ extern (C++) final class Module : Package
bool isHdrFile; // if it is a header (.di) file
bool isDocFile; // if it is a documentation input file, not D source
bool isPackageFile; // if it is a package.d
Package pkg; // if isPackageFile is true, the Package that contains this package.d
Strings contentImportedFiles; // array of files whose content was imported
int needmoduleinfo;
int selfimports; // 0: don't know, 1: does not, 2: does
Expand Down Expand Up @@ -1106,15 +1107,27 @@ else
*
* To avoid the conflict:
* 1. If preceding package name insertion had occurred by Package::resolve,
* later package.d loading will change Package::isPkgMod to PKG.module_ and set Package::mod.
* reuse the previous wrapping 'Package' if it exists
* 2. Otherwise, 'package.d' wrapped by 'Package' is inserted to the internal tree in here.
*
* Then change Package::isPkgMod to PKG.module_ and set Package::mod.
*
* Note that the 'wrapping Package' is the Package that contains package.d and other submodules,
* the one inserted to the symbol table.
*/
auto p = new Package(Loc.initial, ident);
auto ps = dst.lookup(ident);
Package p = ps ? ps.isPackage() : null;
if (p is null)
{
p = new Package(Loc.initial, ident);
p.tag = this.tag; // reuse the same package tag
p.symtab = new DsymbolTable();
}
this.tag = p.tag; // reuse the 'older' package tag
this.pkg = p;
p.parent = this.parent;
p.isPkgMod = PKG.module_;
p.mod = this;
p.tag = this.tag; // reuse the same package tag
p.symtab = new DsymbolTable();
s = p;
}
if (!dst.insert(s))
Expand All @@ -1138,16 +1151,9 @@ else
}
else if (Package pkg = prev.isPackage())
{
if (pkg.isPkgMod == PKG.unknown && isPackageFile)
{
/* If the previous inserted Package is not yet determined as package.d,
* link it to the actual module.
*/
pkg.isPkgMod = PKG.module_;
pkg.mod = this;
pkg.tag = this.tag; // reuse the same package tag
// 'package.d' loaded after a previous 'Package' insertion
if (isPackageFile)
amodules.push(this); // Add to global array of all modules
}
else
error(md ? md.loc : loc, "from file %s conflicts with package name %s", srcname, pkg.toChars());
}
Expand Down
8 changes: 6 additions & 2 deletions dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -2381,6 +2381,8 @@ Package resolveIsPackage(Dsymbol sym)
}
pkg = imp.pkg;
}
else if (auto mod = sym.isModule())
pkg = mod.isPackageFile ? mod.pkg : sym.isPackage();
else
pkg = sym.isPackage();
if (pkg)
Expand Down Expand Up @@ -5788,7 +5790,9 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
}

// save expression as a string before any semantic expansion
auto assertExpMsg = exp.msg ? null : exp.toChars();
// if -checkaction=context is enabled an no message exists
const generateMsg = !exp.msg && global.params.checkAction == CHECKACTION.context;
auto assertExpMsg = generateMsg ? exp.toChars() : null;

if (Expression ex = unaSemantic(exp, sc))
{
Expand All @@ -5800,7 +5804,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
exp.e1 = exp.e1.optimize(WANTvalue);
exp.e1 = exp.e1.toBoolean(sc);

if (!exp.msg && global.params.checkAction == CHECKACTION.context)
if (generateMsg)
// no message - use assert expression as msg
{
/*
Expand Down
1 change: 1 addition & 0 deletions dmd/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Module : public Package
bool isHdrFile; // if it is a header (.di) file
bool isDocFile; // if it is a documentation input file, not D source
bool isPackageFile; // if it is a package.d
Package *pkg; // if isPackageFile is true, the Package that contains this package.d
Strings contentImportedFiles; // array of files whose content was imported
int needmoduleinfo;
int selfimports; // 0: don't know, 1: does not, 2: does
Expand Down
2 changes: 1 addition & 1 deletion runtime/druntime
Submodule druntime updated 2 files
+1 −0 mak/DOCS
+3 −0 posix.mak