Skip to content

Commit

Permalink
Merge pull request #3736 from 9rnsr/fix13087
Browse files Browse the repository at this point in the history
[REG2.066a] Issue 13087 - Error: no property 'xyz' for type 'Vec!4'
  • Loading branch information
WalterBright committed Jul 11, 2014
2 parents 69aebf0 + 3799592 commit 49f0db5
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cast.c
Expand Up @@ -3425,7 +3425,7 @@ IntRange getIntRange(Expression *e)
if (vd && vd->range)
range = vd->range->cast(e->type);
else if (vd && vd->init && !vd->type->isMutable() &&
(ie = vd->getConstInitializer()))
(ie = vd->getConstInitializer()) != NULL)
ie->accept(this);
else
visit((Expression *)e);
Expand Down
18 changes: 17 additions & 1 deletion src/mtype.c
Expand Up @@ -1037,6 +1037,20 @@ Type *Type::addSTC(StorageClass stc)
return t;
}

/************************************
* Convert MODxxxx to STCxxx
*/

StorageClass ModToStc(unsigned mod)
{
StorageClass stc;
if (mod & MODimmutable) stc |= STCimmutable;
if (mod & MODconst) stc |= STCconst;
if (mod & MODwild) stc |= STCwild;
if (mod & MODshared) stc |= STCshared;
return stc;
}

/************************************
* Apply MODxxxx bits to existing type.
*/
Expand Down Expand Up @@ -6496,7 +6510,9 @@ void TypeQualified::resolveHelper(Loc loc, Scope *sc,
if (v->storage_class & (STCconst | STCimmutable | STCmanifest) ||
v->type->isConst() || v->type->isImmutable())
{
goto L3;
// Bugzilla 13087: this.field is not constant always
if (!v->isThisDeclaration())
goto L3;
}
}
if (!sm)
Expand Down
1 change: 1 addition & 0 deletions src/mtype.h
Expand Up @@ -54,6 +54,7 @@ class TypeTuple;
void semanticTypeInfo(Scope *sc, Type *t);
MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes, unsigned *wm = NULL, size_t inferStart = 0);
Type *reliesOnTident(Type *t, TemplateParameters *tparams = NULL, size_t iStart = 0);
StorageClass ModToStc(unsigned mod);

enum ENUMTY
{
Expand Down
5 changes: 4 additions & 1 deletion src/template.c
Expand Up @@ -2597,7 +2597,10 @@ FuncDeclaration *TemplateDeclaration::doHeaderInstantiation(
hasttp = true;
}
if (hasttp)
tf = (TypeFunction *)tf->addMod(tthis->mod);
{
tf = (TypeFunction *)tf->addSTC(ModToStc(tthis->mod));
assert(!tf->deco);
}
}

Scope *scx = sc2->push();
Expand Down
19 changes: 19 additions & 0 deletions test/compilable/ice13088.d
@@ -0,0 +1,19 @@
// REQUIRED_ARGS: -o-
// PERMUTE_ARGS:

struct X
{
void mfoo(this T)() {}
}
void test()
{
shared const X scx;

scx.mfoo();
}

struct Vec
{
int x;
void sc() shared const {}
}
22 changes: 22 additions & 0 deletions test/runnable/template9.d
Expand Up @@ -3456,6 +3456,28 @@ void test9708()
void f12880(T)(in T value) { static assert(is(T == string)); }
void test12880() { f12880(string.init); }

/******************************************/
// 13087

struct Vec13087
{
int x;
void m() { auto n = component13087!(this, 'x'); }
void c() const { auto n = component13087!(this, 'x'); }
void w() inout { auto n = component13087!(this, 'x'); }
void wc() inout const { auto n = component13087!(this, 'x'); }
void s() shared { auto n = component13087!(this, 'x'); }
void sc() shared const { auto n = component13087!(this, 'x'); }
void sw() shared inout { auto n = component13087!(this, 'x'); }
void swc() shared inout const { auto n = component13087!(this, 'x'); }
void i() immutable { auto n = component13087!(this, 'x'); }
}

template component13087(alias vec, char c)
{
alias component13087 = vec.x;
}

/******************************************/

int main()
Expand Down

0 comments on commit 49f0db5

Please sign in to comment.