www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12290] New: IFTI should consider implicit conversions of the literal arguments

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12290

           Summary: IFTI should consider implicit conversions of the
                    literal arguments
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg gmail.com> 2014-03-03 00:15:25 PST ---
Test case:

inout(V) get(K, V)(inout(V[K]) aa, K key, lazy inout(V) defaultValue)
{
    auto p = key in aa;
    return p ? *p : defaultValue;
}

void main()
{
    short[short] aa = [1:10, 2:20];

    short n = get(aa, 5, 50);
    // IFTI should deduce K=short, V=short from the arguments
    // !()(short[short], int, int)
    // because 1 and 2 are implicitly convertible to short
    // , and 10 and 20 are implicitly convertible to short

    assert(n == 50);
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 03 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12290


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2014-03-03 01:22:22 PST ---
https://github.com/D-Programming-Language/dmd/pull/3353

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 03 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12290



--- Comment #2 from github-bugzilla puremagic.com 2014-03-03 07:06:18 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/bdcee4d07905130240b0cacd604354994ddc915d
fix Issue 12290 - IFTI should consider implicit conversions of the literal
arguments

https://github.com/D-Programming-Language/dmd/commit/826b764fd4a133ebf1179e76d8df9d8241032e3c
Merge pull request #3353 from 9rnsr/fix12290

Issue 12290 - IFTI should consider implicit conversions of the literal
arguments

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 03 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12290


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 03 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12290


Steven Schveighoffer <schveiguy yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy yahoo.com


--- Comment #3 from Steven Schveighoffer <schveiguy yahoo.com> 2014-03-03
07:35:11 PST ---
Somewhat related to issue 4998

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 03 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12290



--- Comment #4 from Kenji Hara <k.hara.pg gmail.com> 2014-03-03 08:03:59 PST ---
(In reply to comment #3)
 Somewhat related to issue 4998

It's not related (and looks to me that would be impossible) issue. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 03 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12290



--- Comment #5 from Steven Schveighoffer <schveiguy yahoo.com> 2014-03-03
08:10:38 PST ---
Definitely related. In both cases, the compiler is inferring the type of the
literal based on the defined type of the literal rather than how it's used. In
both cases, choosing a smaller integer type will satisfy the call, and should
be done.

Yes, in 4998, the example does not provide enough information in the signature
itself to figure out the correct type to use, which is why the proposal is
given.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 03 2014