Bug 8570 – Tuples without named fields should implicitly convert to tuples with named fields when returned from a function

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-08-20T23:24:00Z
Last change time
2017-07-02T18:32:46Z
Assigned to
nobody
Creator
simen.kjaras

Comments

Comment #0 by simen.kjaras — 2012-08-20T23:24:48Z
Currently, this compiles: void bar( ) { Tuple!( int, "a", float, "b" ) t = tuple( 1, 2.0 ); } And this does not: Tuple!( int, "a", float, "b" ) foo( ) { return tuple( 1, 2.0 ); } Ref. discussion: http://forum.dlang.org/thread/[email protected]?page=8#post-jul0qv:242l9d:241:40digitalmars.com
Comment #1 by simen.kjaras — 2012-11-12T08:49:08Z
*** Issue 8970 has been marked as a duplicate of this issue. ***
Comment #2 by dlang-bugzilla — 2017-07-02T18:32:46Z
Reduced: struct S { this(int) {} } void bar() { S s = 5; } S foo() { return 5; } The first is an initialization / assignment; the second is an implicit conversion. Currently D does not allow defining implicit conversions to arbitrary types (closest is alias this, but it can alias only specific types). Providing some way for types to do implicit conversions to arbitrary other types is a much bigger discussion outside of the scope of this issue.