Bug 6454 – @property doesn't need return type

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-08-08T03:23:22Z
Last change time
2018-05-14T10:54:00Z
Assigned to
No Owner
Creator
simendsjo

Comments

Comment #0 by simendsjo — 2011-08-08T03:23:22Z
For @property, the return type is inferred even without the auto return type: struct S { @property p() { // missing bool/auto return true; } } void main() { S s; static assert(is(typeof(s.p) == bool)); // ok }
Comment #1 by simendsjo — 2011-08-08T03:25:06Z
This also breaks creation of import files. Notice the double @property: // D import file generated from 't.d' struct S { @property @property p() { return true; } } void main();
Comment #2 by k.hara.pg — 2011-09-21T06:40:58Z
(In reply to comment #0) > For @property, the return type is inferred even without the auto return type: > > struct S { > @property p() { // missing bool/auto > return true; > } > } > void main() { > S s; > static assert(is(typeof(s.p) == bool)); // ok > } Maybe this is expected feature, but spec does not describe it. http://d-programming-language.org/declaration.html > Decl: > StorageClasses Decl > BasicType Declarators ; > BasicType Declarator FunctionBody > AutoDeclaration (In reply to comment #1) > This also breaks creation of import files. Notice the double @property: > > // D import file generated from 't.d' > struct S > { > @property @property p() > { > return true; > } > } > void main(); This is same as issue 6360.
Comment #3 by lt.infiltrator — 2014-03-19T21:14:54Z
So where are we with this? Is this a "feature not a bug"?
Comment #4 by nick — 2018-05-14T10:54:00Z
The spec has been updated to list `Property` under `StorageClass`: https://dlang.org/spec/declaration.html#StorageClass