diff --git a/dmd2/attrib.c b/dmd2/attrib.c index 245cb084..de5c92bb 100644 --- a/dmd2/attrib.c +++ b/dmd2/attrib.c @@ -453,6 +453,7 @@ void StorageClassDeclaration::setScope(Scope *sc) if (stc & (STCsafe | STCtrusted | STCsystem)) scstc &= ~(STCsafe | STCtrusted | STCsystem); scstc |= stc; + //printf("scstc = x%llx\n", scstc); setScopeNewSc(sc, scstc, sc->linkage, sc->protection, sc->explicitProtection, sc->structalign); } diff --git a/dmd2/dsymbol.c b/dmd2/dsymbol.c index f6563ccb..ef23de74 100644 --- a/dmd2/dsymbol.c +++ b/dmd2/dsymbol.c @@ -329,7 +329,7 @@ int Dsymbol::isAnonymous() void Dsymbol::setScope(Scope *sc) { - //printf("Dsymbol::setScope() %p %s\n", this, toChars()); + //printf("Dsymbol::setScope() %p %s, %p stc = %llx\n", this, toChars(), sc, sc->stc); if (!sc->nofree) sc->setNoFree(); // may need it even after semantic() finishes scope = sc; @@ -1110,7 +1110,7 @@ static int dimDg(void *ctx, size_t n, Dsymbol *) size_t ScopeDsymbol::dim(Dsymbols *members) { size_t n = 0; - foreach(members, &dimDg, &n); + foreach(NULL, members, &dimDg, &n); return n; } #endif @@ -1143,7 +1143,7 @@ static int getNthSymbolDg(void *ctx, size_t n, Dsymbol *sym) Dsymbol *ScopeDsymbol::getNth(Dsymbols *members, size_t nth, size_t *pn) { GetNthSymbolCtx ctx = { nth, NULL }; - int res = foreach(members, &getNthSymbolDg, &ctx); + int res = foreach(NULL, members, &getNthSymbolDg, &ctx); return res ? ctx.sym : NULL; } #endif @@ -1158,7 +1158,7 @@ Dsymbol *ScopeDsymbol::getNth(Dsymbols *members, size_t nth, size_t *pn) */ #if DMDV2 -int ScopeDsymbol::foreach(Dsymbols *members, ScopeDsymbol::ForeachDg dg, void *ctx, size_t *pn) +int ScopeDsymbol::foreach(Scope *sc, Dsymbols *members, ScopeDsymbol::ForeachDg dg, void *ctx, size_t *pn) { assert(dg); if (!members) @@ -1170,9 +1170,9 @@ int ScopeDsymbol::foreach(Dsymbols *members, ScopeDsymbol::ForeachDg dg, void *c { Dsymbol *s = (*members)[i]; if (AttribDeclaration *a = s->isAttribDeclaration()) - result = foreach(a->include(NULL, NULL), dg, ctx, &n); + result = foreach(sc, a->include(sc, NULL), dg, ctx, &n); else if (TemplateMixin *tm = s->isTemplateMixin()) - result = foreach(tm->members, dg, ctx, &n); + result = foreach(sc, tm->members, dg, ctx, &n); else if (s->isTemplateInstance()) ; else diff --git a/dmd2/dsymbol.h b/dmd2/dsymbol.h index c905ebf9..b895d9a2 100644 --- a/dmd2/dsymbol.h +++ b/dmd2/dsymbol.h @@ -325,7 +325,7 @@ struct ScopeDsymbol : Dsymbol static Dsymbol *getNth(Dsymbols *members, size_t nth, size_t *pn = NULL); typedef int (*ForeachDg)(void *ctx, size_t idx, Dsymbol *s); - static int foreach(Dsymbols *members, ForeachDg dg, void *ctx, size_t *pn=NULL); + static int foreach(Scope *sc, Dsymbols *members, ForeachDg dg, void *ctx, size_t *pn=NULL); ScopeDsymbol *isScopeDsymbol() { return this; } }; diff --git a/dmd2/expression.c b/dmd2/expression.c index 5fdf13ec..c2a4a3b3 100644 --- a/dmd2/expression.c +++ b/dmd2/expression.c @@ -2981,7 +2981,7 @@ Lagain: if (ti) { if (!ti->semanticRun) ti->semantic(sc); - s = ti->inst->toAlias(); + s = ti->toAlias(); if (!s->isTemplateInstance()) goto Lagain; e = new ScopeExp(loc, ti); diff --git a/dmd2/module.c b/dmd2/module.c index 75aa88a8..367ed43b 100644 --- a/dmd2/module.c +++ b/dmd2/module.c @@ -812,7 +812,14 @@ void Module::parse() if (md) { this->ident = md->id; this->safe = md->safe; - dst = Package::resolve(md->packages, &this->parent, NULL); + Package *ppack = NULL; + dst = Package::resolve(md->packages, &this->parent, &ppack); + if (ppack && ppack->isModule()) + { + 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; + } } else { @@ -837,7 +844,7 @@ void Module::parse() { Package *pkg = prev->isPackage(); assert(pkg); - error(loc, "from file %s conflicts with package name %s", + error(pkg->loc, "from file %s conflicts with package name %s", srcname, pkg->toChars()); } } @@ -1358,7 +1365,8 @@ DsymbolTable *Package::resolve(Identifiers *packages, Dsymbol **pparent, Package #else if (p->isModule()) { // Return the module so that a nice error message can be generated - *ppkg = (Package *)p; + if (ppkg) + *ppkg = (Package *)p; break; } #endif diff --git a/dmd2/mtype.c b/dmd2/mtype.c index 7502dc17..8dc23d7e 100644 --- a/dmd2/mtype.c +++ b/dmd2/mtype.c @@ -1360,8 +1360,11 @@ Type *Type::aliasthisOf() // of errors which occured. if (spec && global.errors != olderrs) spec->errors = global.errors - olderrs; + tf = (TypeFunction *)fd->type; } - t = ((TypeFunction *)fd->type)->next; + t = tf->next; + if (tf->isWild()) + t = t->substWildTo(mod == 0 ? MODmutable : mod); } } return t; diff --git a/dmd2/statement.c b/dmd2/statement.c index a0be3353..07310de1 100644 --- a/dmd2/statement.c +++ b/dmd2/statement.c @@ -4737,7 +4737,9 @@ Catch *Catch::syntaxCopy() } void Catch::semantic(Scope *sc) -{ ScopeDsymbol *sym; +{ + if (type && type->deco) + return; //printf("Catch::semantic(%s)\n", ident->toChars()); @@ -4754,7 +4756,7 @@ void Catch::semantic(Scope *sc) } #endif - sym = new ScopeDsymbol(); + ScopeDsymbol *sym = new ScopeDsymbol(); sym->parent = sc->scopesym; sc = sc->push(sym); diff --git a/dmd2/template.c b/dmd2/template.c index 70a0b934..63f8ae54 100644 --- a/dmd2/template.c +++ b/dmd2/template.c @@ -477,8 +477,10 @@ void TemplateDeclaration::semantic(Scope *sc) /* Remember Scope for later instantiations, but make * a copy since attributes can change. */ - this->scope = new Scope(*sc); - this->scope->setNoFree(); + if (!this->scope) + { this->scope = new Scope(*sc); + this->scope->setNoFree(); + } // Set up scope for parameters ScopeDsymbol *paramsym = new ScopeDsymbol(); diff --git a/dmd2/traits.c b/dmd2/traits.c index 18e38ecb..911fc6fe 100644 --- a/dmd2/traits.c +++ b/dmd2/traits.c @@ -396,7 +396,8 @@ Expression *TraitsExp::semantic(Scope *sc) }; Identifiers *idents = new Identifiers; - ScopeDsymbol::foreach(sd->members, &PushIdentsDg::dg, idents); + + ScopeDsymbol::foreach(sc, sd->members, &PushIdentsDg::dg, idents); ClassDeclaration *cd = sd->isClassDeclaration(); if (cd && ident == Id::allMembers) @@ -407,7 +408,7 @@ Expression *TraitsExp::semantic(Scope *sc) { for (size_t i = 0; i < cd->baseclasses->dim; i++) { ClassDeclaration *cb = (*cd->baseclasses)[i]->base; - ScopeDsymbol::foreach(cb->members, &PushIdentsDg::dg, idents); + ScopeDsymbol::foreach(NULL, cb->members, &PushIdentsDg::dg, idents); if (cb->baseclasses->dim) dg(cb, idents); }