www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11915] New: Inconsistent overload resolution behaviour between `ref` and `out`

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

           Summary: Inconsistent overload resolution behaviour between
                    `ref` and `out`
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com



18:51:08 MSK ---
This code illustrates the inconsistency:
---
void f(int) { }
void f(ref int) { }

void g(int) { }
void g(out int) { }

void main()
{
    const int n = 1;
    f(n); // ok, selects `void f(int)`
    g(n); // Error: constant 1 is not an lvalue
}
---

This is either "accepts-invalid" or "rejects-valid" bug.


The issue is segregated from Issue 11857.

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
           Severity|normal                      |minor




 This code illustrates the inconsistency:
 ---
 void f(int) { }
 void f(ref int) { }
 
 void g(int) { }
 void g(out int) { }
 
 void main()
 {
     const int n = 1;
     f(n); // ok, selects `void f(int)`
     g(n); // Error: constant 1 is not an lvalue
 }
 ---
 
 This is either "accepts-invalid" or "rejects-valid" bug.
 
 
 The issue is segregated from Issue 11857.
This is diagnostic bug. With g(n) case, it should provide more better error message, like: Error: out paraemter does not match non-mutable lvalue 'n' of type 'const int' -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 13 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11915




21:07:37 MSK ---

 This is diagnostic bug.
I still don't understand why does `out` and `ref` behave differently. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 13 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11915


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim maxim-fomin.ru



---


 This code illustrates the inconsistency:
 ---
 void f(int) { }
 void f(ref int) { }
 
 void g(int) { }
 void g(out int) { }
 
 void main()
 {
     const int n = 1;
     f(n); // ok, selects `void f(int)`
     g(n); // Error: constant 1 is not an lvalue
 }
 ---
 
 This is either "accepts-invalid" or "rejects-valid" bug.
 
 
 The issue is segregated from Issue 11857.
This is diagnostic bug. With g(n) case, it should provide more better error message, like: Error: out paraemter does not match non-mutable lvalue 'n' of type 'const int'
Why? Either both should be rejected because lvalue arguements are unsuccessfuly matched to lvalue parameters, or should be both matched to (int) version because compiler is not stupid to do what is described above. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 13 2014