www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8751] New: Problem with pure inference of inner delegate

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

           Summary: Problem with pure inference of inner delegate
           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



alias bool delegate(in int) pure Bar;
Bar foo1(immutable scope int x) pure {
    return y => x > y; // OK
}
Bar foo2(const scope int x) pure {
    return y => x > y; // error
}
Bar foo3(in int x) pure {
    return y => x > y; // error
}
void main() {}



DMD 2.061alpha gives:

temp.d(6): Error: cannot implicitly convert expression (__lambda4) of type bool
delegate(const(int) y) nothrow  safe to bool delegate(const(int)) pure
temp.d(9): Error: cannot implicitly convert expression (__lambda6) of type bool
delegate(const(int) y) nothrow  safe to bool delegate(const(int)) pure


The 'x' arguments are values, and they can't be modified inside foo1/foo2/foo3,
so I think DMD should accept all three versions.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 04 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8751




Current 'scope' storage class for value parameter is no meaning, and 'in'
storage class is identical with const.

Then, simplified test case is:

alias bool delegate(in int) pure Bar;
Bar foo1(immutable int x) pure {
    return y => x > y; // OK
}
Bar foo2(const int x) pure {
    return y => x > y; // error
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8751


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



06:24:42 PDT ---

 Current 'scope' storage class for value parameter is no meaning, and 'in'
 storage class is identical with const.
Wait, is that why I've filed Issue 8749? So the whole 'in' equals 'const scope' is a lie? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8751


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
           Platform|x86                         |All
         OS/Version|Windows                     |All



https://github.com/D-Programming-Language/dmd/pull/1161

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8751




https://github.com/D-Programming-Language/dmd/pull/1161
 Wait, is that why I've filed Issue 8749? So the whole 'in' equals 'const scope'
 is a lie?
I'll comment to there. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8751


yebblies <yebblies gmail.com> changed:

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



https://github.com/D-Programming-Language/dmd/commit/6ecd4f3c9c062d2c297b3dde2f7286314607aa1c

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 09 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8751




This code, that is derived more closely from my use case, gives an error, after
merging the patch:


alias bool delegate(in int) pure Dg;
Dg foo1(immutable Dg f) pure {
    return x => f(x); // OK
}
Dg foo2(const Dg f) pure {
    return x => f(x); // error
}
void main() {}


DMD patched gives:

temp.d(6): Error: cannot implicitly convert expression (__lambda4) of type bool
delegate(const(int) x)  system to bool delegate(const(int)) pure

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 09 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8751





 This code, that is derived more closely from my use case, gives an error, after
 merging the patch:
Moved to Issue 8793 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 10 2012