https://issues.dlang.org/show_bug.cgi?id=19906
Issue ID: 19906
Summary: __traits(isRef) always yields false for auto ref
parameter
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
Consider:
import std.stdio;
void fun(T)(auto ref T x) {
pragma(msg, __PRETTY_FUNCTION__);
static if (is(__traits(isRef, x))) { writeln("ref: ", x); }
else { writeln("non ref: ", x); }
}
void main() {
int a;
fun(a);
fun(42);
}
This prints:
void onlineapp.fun!int.fun(ref int x)
void onlineapp.fun!int.fun(int x)
non ref: 0
non ref: 42
It should print:
void onlineapp.fun!int.fun(ref int x)
void onlineapp.fun!int.fun(int x)
ref: 0
non ref: 42
--