Bug 11525 – REG(2.065): Error: 'a[] *= a[]' each element is not a scalar, it is a Complex!double

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-16T01:15:00Z
Last change time
2013-11-30T09:10:08Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
timothee.cour2

Comments

Comment #0 by timothee.cour2 — 2013-11-16T01:15:17Z
works in 2.064.2, fails in 2.065 import std.complex; void main(){ auto a=[Complex!double.init]; a[]*=a[]; }
Comment #1 by yebblies — 2013-11-16T01:27:53Z
I'm not sure this is supposed to work... Structs with overloaded operators generally don't work with array operations.
Comment #2 by timothee.cour2 — 2013-11-16T01:32:00Z
(In reply to comment #1) > I'm not sure this is supposed to work... Structs with overloaded operators > generally don't work with array operations. I don't see why it shouldn't be allowed (besides the fact that it did work up till now). Without this complex numbers are very much 2nd class citizens for example.
Comment #3 by yebblies — 2013-11-16T03:07:08Z
Yes, but unless the 2.064 behavior was intentional, this is an enhancement and not a regression. I remember this being discussed before but I don't know where.
Comment #4 by k.hara.pg — 2013-11-27T07:59:39Z
(In reply to comment #2) > (In reply to comment #1) > > I'm not sure this is supposed to work... Structs with overloaded operators > > generally don't work with array operations. > > I don't see why it shouldn't be allowed (besides the fact that it did work up > till now). Without this complex numbers are very much 2nd class citizens for > example. This change was introduced by fixing bug 11376. (In reply to comment #3) > Yes, but unless the 2.064 behavior was intentional, this is an enhancement and > not a regression. I remember this being discussed before but I don't know > where. If an used array-op is not directly implemented in druntime, compiler will implicitly generate a function to implement the required array-op by using for-loop. So, if the array-op operand properly supports arithmetic operations (+, -, *, /, ...), corresponding array-op should also be accepted. So, this is really a regression IMO.
Comment #5 by k.hara.pg — 2013-11-27T08:42:20Z
Comment #6 by github-bugzilla — 2013-11-30T08:38:17Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/46bee52320310ed25e838e0dc3d99224fd7e6596 fix Issue 11525 - Error: 'a[] *= a[]' each element is not a scalar, it is a Complex!double https://github.com/D-Programming-Language/dmd/commit/9a7ebe8f4b84f406a68bb27fe11d1a769767278b Merge pull request #2891 from 9rnsr/fix11525 [REG2.065a] Issue 11525 - Error: 'a[] *= a[]' each element is not a scalar, it is a Complex!double