digitalmars.D.bugs - opIndex in struct
- Bent Rasmussen (15/16) Jul 14 2004 test.d(15): cannot implicitly convert int to test
- Stewart Gordon (12/29) Jul 15 2004 There aren't 15 lines in your code. So we have yet another line
- Bent Rasmussen (9/16) Jul 15 2004 No. I just sliced the relevant piece of the code to make the case shorte...
dmd test.dtest.d(15): cannot implicitly convert int to test struct test { bit x; bit opIndexAssign(bit v, uint i) { return x = v; } void ex() { this[0] = true; // oops } } The error does not manifest if test is a class. DMD 0.95 XP SP1
Jul 14 2004
Bent Rasmussen wrote:There aren't 15 lines in your code. So we have yet another line numbering bug?dmd test.dtest.d(15): cannot implicitly convert int to teststruct test { bit x; bit opIndexAssign(bit v, uint i) { return x = v; } void ex() { this[0] = true; // oops } } The error does not manifest if test is a class.I think it's an issue with this in struct actually. In a struct, this means the address of the current object. Don't ask me why. (*this)[0] = true; should work. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Jul 15 2004
There aren't 15 lines in your code. So we have yet another line numbering bug?No. I just sliced the relevant piece of the code to make the case shorter, and inserted a comment on the interesting line. I didn't figure this was relevant module test; ... void main { }I think it's an issue with this in struct actually. In a struct, this means the address of the current object. Don't ask me why. (*this)[0] = true; should work.Thanks. Excuse the noise. :-)
Jul 15 2004