digitalmars.D.bugs - 0.126: New Struct Error
- John Reimer <brk_6502 yahoo.com> Jun 09 2005
- "Regan Heath" <regan netwin.co.nz> Jun 09 2005
- John Reimer <brk_6502 yahoo.com> Jun 09 2005
- Sean Kelly <sean f4.ca> Jun 09 2005
- John Reimer <brk_6502 yahoo.com> Jun 09 2005
- "Walter" <newshound digitalmars.com> Jun 14 2005
- "Walter" <newshound digitalmars.com> Jun 14 2005
- "Uwe Salomon" <post uwesalomon.de> Jun 09 2005
The code (much reduced from original):
# module test;
#
# struct Entry
# {
# Entry* create()
# {
# Entry* theEntry = new Entry;
# return theEntry;
# }
# }
#
# class Container
# {
# void add()
# {
# Entry* add = Entry.create();
# // ....
# }
# }
Produces this error message (courtesy of dmd 0.126 on linux):
test.d(16): this for create needs to be type Entry not type test.Container
Can anybody decipher that message? That's verbatum! I'm not sure why
it's not working either. This compiled on previous versions.
-JJR
Jun 09 2005
On Thu, 09 Jun 2005 04:55:25 -0700, John Reimer <brk_6502 yahoo.com> wrote:# module test; # # struct Entry # { # Entry* create() # { # Entry* theEntry = new Entry; # return theEntry; # } # } # # class Container # { # void add() #{ # Entry* add = Entry.create(); # // .... # } # }
Adding 'static' to create seems to fix it. eg. "static Entry* create()" etc. Regan
Jun 09 2005
Regan Heath wrote:Adding 'static' to create seems to fix it. eg. "static Entry* create()" etc. Regan
Thanks. I'm curious to know why this changes in the recent version. -JJR
Jun 09 2005
In article <d8a3e5$23gj$1 digitaldaemon.com>, John Reimer says...Regan Heath wrote:Adding 'static' to create seems to fix it. eg. "static Entry* create()" etc.
Thanks. I'm curious to know why this changes in the recent version.
The error message stinks, but you should not be able to call a nonstatic method on a type unless it's through an instance of that type. I'm surprised that code ever worked. Sean
Jun 09 2005
Sean Kelly wrote:In article <d8a3e5$23gj$1 digitaldaemon.com>, John Reimer says...Regan Heath wrote:Adding 'static' to create seems to fix it. eg. "static Entry* create()" etc.
Thanks. I'm curious to know why this changes in the recent version.
The error message stinks, but you should not be able to call a nonstatic method on a type unless it's through an instance of that type. I'm surprised that code ever worked. Sean
Thanks. That makes sense. I was wondering if structs had an implicit static attribute on there methods in past versions. I haven't used structs much. With classes, I can see the necessity of using static. -JJR
Jun 09 2005
"John Reimer" <brk_6502 yahoo.com> wrote in message news:d8a5pn$25s9$1 digitaldaemon.com...Thanks. That makes sense. I was wondering if structs had an implicit static attribute on there methods in past versions.
No. You'd just get passed the wrong 'this'. If you accessed a member, a mess would happen.
Jun 14 2005
"John Reimer" <brk_6502 yahoo.com> wrote in message news:d8a3e5$23gj$1 digitaldaemon.com...Regan Heath wrote:Adding 'static' to create seems to fix it. eg. "static Entry* create()" etc. Regan
Thanks. I'm curious to know why this changes in the recent version.
Because it now checks for that particular mistake. Before, it would pass the wrong 'this' pointer to Entry.create().
Jun 14 2005
The code (much reduced from original): # module test; # # struct Entry # {
Insert a "static" here.# Entry* create() # { # Entry* theEntry = new Entry; # return theEntry; # } # } # # class Container # { # void add() # { # Entry* add = Entry.create(); # // .... # } # }
Ciao uwe
Jun 09 2005









"Walter" <newshound digitalmars.com> 