Bug 686 – [Regression] opCast of a struct or union is called in nonsensical circumstances
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-12-13T13:58:00Z
Last change time
2014-02-15T13:20:10Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
smjg
Comments
Comment #0 by smjg — 2006-12-13T13:58:05Z
This used to work. But now, it's broken the bit array/pointer types in my utility library.
----------
struct Qwert {
Yuiop opCast() {
return Yuiop.init;
}
}
struct Yuiop {
Qwert asdfg() {
return Qwert.init;
}
void hjkl() {
Qwert zxcvb = asdfg(); // line 13
}
}
----------
opCast_struct.d(13): Error: cannot implicitly convert expression (((this.asdfg)().opCast)()) of type Yuiop to Qwert
----------
There's absolutely no reason that it should be trying to call Qwert.opCast. adsfg() is already of type qwert; even if it wasn't, this wouldn't make sense since "Overloading the cast operator does not affect implicit casts, it only applies to explicit casts."
If Qwert.opCast is removed, the code compiles without error.