Bug 13773 – std.traits.ReturnType does not resolve inout

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-11-25T08:40:10Z
Last change time
2019-12-20T14:32:24Z
Assigned to
No Owner
Creator
Martin Nowak

Comments

Comment #0 by code — 2014-11-25T08:40:10Z
cat > bug.d << CODE import std.traits; struct Foo { inout(int)[] keys() inout @property { return null; } } void main() { Foo m; const(Foo) c; immutable(Foo) i; pragma(msg, typeof(m.keys), ", ", ReturnType!(m.keys)); pragma(msg, typeof(c.keys), ", ", ReturnType!(c.keys)); pragma(msg, typeof(i.keys), ", ", ReturnType!(i.keys)); } CODE dmd -c bug ---- int[], inout(int)[] const(int)[], inout(int)[] immutable(int)[], inout(int)[] ----
Comment #1 by k.hara.pg — 2014-11-25T09:20:24Z
I think this should be marked as invalid or changed as a compiler enhancement, because: 1. ReturnType takes an alias (through the index 0 of the TupleParameter). 2. Currently alias parameter cannot handle the runtime context of the expression, so ReturnType!(m.keys), ReturnType!(c.keys), and ReturnType!(i.keys) are perfectly same with ReturnType!(Foo.keys). 3. The return type of Foo.keys is inout(int)[].