January 04, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7225

           Summary: immutable argument by const ref
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2012-01-04 14:15:07 PST ---
In this program:
- a1 gives no errors and this is correct;
- a2 gives an error, and I think this is correct;
- a3 too gives an error, and I think this is not correct, because it not a
manifest constant:


void foo(const ref int[2] M) {}
void main() {
    const int[2] a1 = [1, 2];
    foo(a1);
    enum int[2] a2 = [1, 2]; // line 5
    foo(a2);
    immutable int[2] a3 = [1, 2];
    foo(a3);
}


DMD 2.058head gives:

test.d(6): Error: function test.foo (ref const(int[2u]) M) is not callable
using argument types (int[2u])
test.d(5): Error: [1,2] is not an lvalue
test.d(8): Error: cast(const(int[2u]))a3 is not an lvalue

The first two error messages are not good, I think they should be merged in a single more clear error message relative to just line 6.


A similar program that uses just ints:

void foo(const ref int M) {}
void main() {
    const int a1 = 1;
    foo(a1);
    enum int a2 = 1;
    foo(a2);
    immutable int a3 = 1;
    foo(a3);
}


DMD 2.058head gives:

test.d(6): Error: function test3.foo (ref const(int) M) is not callable using
argument types (int)
test.d(5): Error: constant 1 is not an lvalue
test.d(8): Error: constant 1 is not an lvalue

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 16, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7225


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies@gmail.com
         Resolution|                            |DUPLICATE


--- Comment #1 from yebblies <yebblies@gmail.com> 2013-01-17 02:06:19 EST ---
*** This issue has been marked as a duplicate of issue 6708 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Top | Discussion index | About this forum | D home