Bug 9258 – opAssign with base class triggers "identity assignment operator overload" error
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-02T11:16:00Z
Last change time
2013-02-24T01:28:44Z
Keywords
ice, pull, rejects-valid
Assigned to
nobody
Creator
siegelords_abode
Comments
Comment #0 by siegelords_abode — 2013-01-02T11:16:22Z
This code worked fine on 2.060, but is broken on 2.061:
class B { }
class A : B // test.d(3): Error: class test.A identity assignment operator overload is illegal
{
void opAssign(B b)
{
}
}
Firstly, the error line is wrong. Secondly, the assignment is not an identity assignment, as this, without the overload, does not compile:
A a;
B b;
a = b;
I interpret identity assignment to mean strictly assignment of one type to the same type.
Comment #1 by andrej.mitrovich — 2013-01-12T19:26:55Z
Introduced by:
commit 9ee798f73a2f7765a68bbe8f40ff292f551dab72
Author: k-hara <[email protected]>
Date: Sat May 26 02:06:20 2012 +0900
Relax opAssign signature.
Class type that has identity opAssign is disallowed both it is templated or not.
Comment #4 by siegelords_abode — 2013-02-21T20:10:52Z
Turns out this fix is incomplete. This code is still broken:
class B
{
}
class A : B
{
alias set opAssign;
void set(B a)
{
}
}
and it throws an ICE:
dmd: clone.c:35: FuncDeclaration* AggregateDeclaration::hasIdentityOpAssign(Scope*, Dsymbol*): Assertion `assign->ident == Id::assign' failed.
This is actually the closer to the original code that had the bug... shows me right to try to reduce the code... I get a reduced fix!
Comment #5 by k.hara.pg — 2013-02-21T22:36:48Z
(In reply to comment #4)
> Turns out this fix is incomplete. This code is still broken:
>
> class B
> {
> }
>
> class A : B
> {
> alias set opAssign;
>
> void set(B a)
> {
> }
> }
>
> and it throws an ICE:
>
> dmd: clone.c:35: FuncDeclaration*
> AggregateDeclaration::hasIdentityOpAssign(Scope*, Dsymbol*): Assertion
> `assign->ident == Id::assign' failed.
>
> This is actually the closer to the original code that had the bug... shows me
> right to try to reduce the code... I get a reduced fix!
https://github.com/D-Programming-Language/dmd/pull/1682
Comment #6 by github-bugzilla — 2013-02-21T23:37:28Z