D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10465 - ReturnType does not store the storage class
Summary: ReturnType does not store the storage class
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-24 13:55 UTC by Andrej Mitrovic
Modified: 2020-03-21 03:56 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2013-06-24 13:55:34 UTC
-----
import std.traits;

ref int foo(ref int);

void main()
{
    alias ReturnType!foo function(ParameterTypeTuple!foo) Bar;
    int x;
    Bar bar;

    static assert(!__traits(compiles, bar(5) ));  // ok, can't take r-value
    static assert(__traits(compiles, bar(x) ));  // ok, takes l-value

    pragma(msg, Bar);  // 'int function(ref int)' -- missing ref return
    bar(x) = 5;  // Error: (*bar)(x) is not an lvalue
}
-----
Comment 1 basile-z 2017-01-23 07:05:31 UTC
But "ref" is not a type ctor (https://dlang.org/spec/declaration.html#typequal_vs_storageclass). The alias returned by ReturnType type is correct.