Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
10236c8
Implemented tail-const for classes as "const(Object)ref".
michelf Dec 1, 2010
11850ae
Finalized implementation of const(Object)ref syntax, now works with U…
michelf Dec 4, 2010
e5385fa
Now checking head-const in some expressions.
michelf Dec 4, 2010
a7986e8
Fix for typeinfo generation.
michelf Dec 4, 2010
d23d1e5
Adjustments for foreach and array ops with const(Object)ref.
michelf Dec 5, 2010
ad046d3
Fixed small mistake introduced in TypeInfo_Shared by last commit..
michelf Dec 5, 2010
8eb9b17
Added const(Object)ref related tests.
michelf Dec 5, 2010
e5a3a7b
Improved error messages around ref suffix.
michelf Dec 18, 2010
613a7f7
Call tm->merge() for class type in constness typeinfo declarations (w…
michelf Dec 18, 2010
ccd1ced
Handle ref suffix in template type deduction by ignoring it (for now)
michelf Dec 18, 2010
841e81a
Type deduction now takes into account the modifiers for explicit 'ref…
michelf Dec 30, 2010
031c32b
Implemented "correct" behaviour for head modifiers in type deduction.
michelf Jan 23, 2011
239c013
Added a few tests.
michelf Jan 23, 2011
af3acbc
Disabled some failing inout tests.
michelf Jan 23, 2011
ba14ab6
Merge branch 'master' into const-object-ref
michelf Jan 30, 2011
bb5a775
Fixed infinite loop in type merge.
michelf Jan 30, 2011
5e807be
Spacing issues
michelf Feb 6, 2011
290452b
Merge remote branch 'd/master' into const-object-ref
michelf Feb 6, 2011
a20424c
Fix for testaa; cast()(x) now makes mutable only the head reference.
michelf Feb 6, 2011
7380ce7
Cleanup of some tests.
michelf Feb 6, 2011
0ec41d8
Merge remote branch 'd/master' into const-object-ref
michelf Jul 17, 2011
42e7f23
Fix test suite since const(Object)ref changes cast(modifier).
michelf Jul 17, 2011
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
4 changes: 2 additions & 2 deletions src/cast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1734,8 +1734,8 @@ int typeMerge(Scope *sc, Expression *e, Type **pt, Expression **pe1, Expression
}
else if (t1->ty == Tclass || t2->ty == Tclass)
{
if (t1->mod != t2->mod)
{ unsigned char mod = MODmerge(t1->mod, t2->mod);
if (t1->head()->mod != t2->head()->mod)
{ unsigned char mod = MODmerge(t1->head()->mod, t2->head()->mod);
t1 = t1->castMod(mod);
t2 = t2->castMod(mod);
t = t1;
Expand Down
13 changes: 7 additions & 6 deletions src/declaration.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void Declaration::checkModify(Loc loc, Scope *sc, Type *t)
if (sc->incontract && isResult())
error(loc, "cannot modify result '%s' in contract", toChars());

if (isCtorinit() && !t->isMutable())
if (isCtorinit() && !t->head()->isMutable())
{ // It's only modifiable if inside the right constructor
Dsymbol *s = sc->func;
while (1)
Expand Down Expand Up @@ -904,16 +904,17 @@ void VarDeclaration::semantic(Scope *sc)

/* Adjust storage class to reflect type
*/
if (type->isConst())
Type *thead = type->head();
if (thead->isConst())
{ storage_class |= STCconst;
if (type->isShared())
if (thead->isShared())
storage_class |= STCshared;
}
else if (type->isImmutable())
else if (thead->isImmutable())
storage_class |= STCimmutable;
else if (type->isShared())
else if (thead->isShared())
storage_class |= STCshared;
else if (type->isWild())
else if (thead->isWild())
storage_class |= STCwild;

if (isSynchronized())
Expand Down
12 changes: 6 additions & 6 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ Expression *Expression::modifiableLvalue(Scope *sc, Expression *e)

// See if this expression is a modifiable lvalue (i.e. not const)
#if DMDV2
if (type && (!type->isMutable() || !type->isAssignable()))
if (type && (!type->head()->isMutable() || !type->isAssignable()))
error("%s is not mutable", e->toChars());
#endif
return toLvalue(sc, e);
Expand Down Expand Up @@ -6548,9 +6548,9 @@ Expression *DotVarExp::modifiableLvalue(Scope *sc, Expression *e)

Type *t1 = e1->type->toBasetype();

if (!t1->isMutable() ||
(t1->ty == Tpointer && !t1->nextOf()->isMutable()) ||
!var->type->isMutable() ||
if (!t1->head()->isMutable() ||
(t1->ty == Tpointer && !t1->nextOf()->head()->isMutable()) ||
!var->type->head()->isMutable() ||
!var->type->isAssignable() ||
var->storage_class & STCmanifest
)
Expand Down Expand Up @@ -9118,7 +9118,7 @@ Expression *IndexExp::modifiableLvalue(Scope *sc, Expression *e)
modifiable = 1;
if (e1->op == TOKstring)
error("string literals are immutable");
if (type && (!type->isMutable() || !type->isAssignable()))
if (type && (!type->head()->isMutable() || !type->head()->isAssignable()))
error("%s isn't mutable", e->toChars());
Type *t1 = e1->type->toBasetype();
if (t1->ty == Taarray)
Expand Down Expand Up @@ -9580,7 +9580,7 @@ Expression *AssignExp::semantic(Scope *sc)
else if (e1->op == TOKslice)
{
Type *tn = e1->type->nextOf();
if (op == TOKassign && tn && (!tn->isMutable() || !tn->isAssignable()))
if (op == TOKassign && tn && (!tn->head()->isMutable() || !tn->head()->isAssignable()))
{ error("slice %s is not mutable", e1->toChars());
return new ErrorExp();
}
Expand Down
2 changes: 1 addition & 1 deletion src/func.c
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ void FuncDeclaration::semantic3(Scope *sc)
for (int i = 0; i < cd->fields.dim; i++)
{ VarDeclaration *v = (VarDeclaration *)cd->fields.data[i];

if (v->ctorinit == 0 && v->isCtorinit() && !v->type->isMutable())
if (v->ctorinit == 0 && v->isCtorinit() && !v->type->head()->isMutable())
error("missing initializer for final field %s", v->toChars());
}
}
Expand Down
Loading