Bug 606 – auto x = property: variable x cannot be declared to be a function

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2006-11-26T14:31:00Z
Last change time
2014-02-15T13:22:04Z
Assigned to
bugzilla
Creator
godaves

Comments

Comment #0 by godaves — 2006-11-26T14:31:47Z
Originally reported here: http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D.bugs&artnum=9210 module test_prop; int prop() { return 0; } void main() { auto x = prop; } C:\>dmd test_prop test_prop.d(4): variable test_prop.main.x cannot be declared to be a function
Comment #1 by bugzilla — 2006-11-30T02:02:57Z
That's as designed. Declaring a variable to be a function makes no sense. You can declare it to be a pointer to a function, though. You can also declare it to be an alias of a function.
Comment #2 by wbaxter — 2006-11-30T02:10:37Z
(In reply to comment #1) > That's as designed. Declaring a variable to be a function makes no sense. You > can declare it to be a pointer to a function, though. You can also declare it > to be an alias of a function. > I think the point of the bug is that because it's invalid to set a variable to a function, this should be interpreted as a function call, and thus make x an int with value 0.
Comment #3 by bugzilla — 2007-07-01T02:13:25Z
Works DMD 2.001.
Comment #4 by thomas-dloop — 2007-07-23T14:55:56Z
This issue was fixed by DMD-0.178. Added to DStress as http://dstress.kuehne.cn/run/a/auto_20_A.d