D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8570 - Tuples without named fields should implicitly convert to tuples with named fields when returned from a function
Summary: Tuples without named fields should implicitly convert to tuples with named fi...
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
: 8970 (view as issue list)
Depends on:
Blocks:
 
Reported: 2012-08-20 23:24 UTC by Simen Kjaeraas
Modified: 2017-07-02 18:32 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 Simen Kjaeraas 2012-08-20 23:24:48 UTC
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/sedknwtlaefrxuflnbez@forum.dlang.org?page=8#post-jul0qv:242l9d:241:40digitalmars.com
Comment 1 Simen Kjaeraas 2012-11-12 08:49:08 UTC
*** Issue 8970 has been marked as a duplicate of this issue. ***
Comment 2 Vladimir Panteleev 2017-07-02 18:32:46 UTC
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.