D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6454 - @property doesn't need return type
Summary: @property doesn't need return type
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-08 03:23 UTC by simendsjo
Modified: 2018-05-14 10:54 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description simendsjo 2011-08-08 03:23:22 UTC
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 simendsjo 2011-08-08 03:25:06 UTC
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 Kenji Hara 2011-09-21 06:40:58 UTC
(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 Infiltrator 2014-03-19 21:14:54 UTC
So where are we with this?  Is this a "feature not a bug"?
Comment 4 Nick Treleaven 2018-05-14 10:54:00 UTC
The spec has been updated to list `Property` under `StorageClass`:

https://dlang.org/spec/declaration.html#StorageClass