Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #363 from 9rnsr/fix9052
Browse files Browse the repository at this point in the history
Issue 9052 - [2.061 alpha] AA.length in a const context tries to call opAssign + no error line number
  • Loading branch information
Alex Rønne Petersen committed Dec 12, 2012
2 parents 26658ac + dd5becb commit 6055cfb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/object.di
Expand Up @@ -398,6 +398,9 @@ private:
size_t hash;
Key key;
Value value;

// Stop creating built-in opAssign
@disable void opAssign(Slot);
}

struct Hashtable
Expand Down
17 changes: 17 additions & 0 deletions src/object_.d
Expand Up @@ -2118,6 +2118,9 @@ private:
size_t hash;
Key key;
Value value;

// Stop creating built-in opAssign
@disable void opAssign(Slot);
}

struct Hashtable
Expand Down Expand Up @@ -2312,6 +2315,20 @@ unittest
assert(a == b);
}

unittest
{
// test for bug 9052
static struct Json {
Json[string] aa;
void opAssign(Json) {}
size_t length() const { return aa.length; }
// This length() instantiates AssociativeArray!(string, const(Json)) to call AA.length(), and
// inside ref Slot opAssign(Slot p); (which is automatically generated by compiler in Slot),
// this.value = p.value would actually fail, because both side types of the assignment
// are const(Json).
}
}

// Scheduled for deprecation in December 2012.
// Please use destroy instead of clear.
alias destroy clear;
Expand Down

0 comments on commit 6055cfb

Please sign in to comment.