Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
October 03, 2010 [Issue 4976] New: Can't use auto on const member functions. | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=4976 Summary: Can't use auto on const member functions. Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: major Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: peter.alexander.au@gmail.com --- Comment #0 from Peter Alexander <peter.alexander.au@gmail.com> 2010-10-02 17:26:27 PDT --- When you try to use type inference on a const member function, you get a compiler error: class Foo { public: auto foo() const { return 0; } } Compiling gives: test.d(4): no identifier for declarator foo test.d(4): semicolon expected, not 'const' test.d(4): Declaration expected, not 'return' Removing the 'const' allows it to compile, but the function can no longer be called on const objects. The same applies for structs and @property methods. This is using DMD 2.049. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 03, 2010 [Issue 4976] Can't use auto on const member functions. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Peter Alexander | http://d.puremagic.com/issues/show_bug.cgi?id=4976 Simen Kjaeraas <simen.kjaras@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |simen.kjaras@gmail.com Resolution| |INVALID --- Comment #1 from Simen Kjaeraas <simen.kjaras@gmail.com> 2010-10-02 17:40:01 PDT --- This is because const and auto are both storage classes. What you want is easily achieved by using this syntax: class Foo { public: const foo( ) { return 0; } } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 03, 2010 [Issue 4976] Can't use auto on const member functions. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Peter Alexander | http://d.puremagic.com/issues/show_bug.cgi?id=4976 --- Comment #2 from Peter Alexander <peter.alexander.au@gmail.com> 2010-10-02 17:51:12 PDT --- Oh, I would have never expected that. Thanks. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 03, 2010 [Issue 4976] Can't use auto on const member functions. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Peter Alexander | http://d.puremagic.com/issues/show_bug.cgi?id=4976 Stewart Gordon <smjg@iname.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |spec Status|RESOLVED |REOPENED CC| |smjg@iname.com Resolution|INVALID | Severity|major |enhancement --- Comment #3 from Stewart Gordon <smjg@iname.com> 2010-10-02 18:43:55 PDT --- But given its counter-intuitiveness, surely this is just a quirk of the grammar, and not a deliberate design feature? I suppose this is really part of the quirk whereby the grammar handles auto as an attribute rather than as what it should be: a placeholder for a type. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 02, 2012 [Issue 4976] Can't use auto on const member functions. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Peter Alexander | http://d.puremagic.com/issues/show_bug.cgi?id=4976 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |FIXED --- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-02 02:25:47 PST --- Fixed in 2.054. https://github.com/D-Programming-Language/dmd/commit/6a15077f8189e1ef203565edaebc766446aa105b -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation