Thread overview
[Issue 8751] New: Problem with pure inference of inner delegate
Oct 04, 2012
Kenji Hara
Oct 04, 2012
Andrej Mitrovic
Oct 04, 2012
Kenji Hara
Oct 04, 2012
Kenji Hara
Oct 09, 2012
yebblies
October 04, 2012
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


--- Comment #0 from bearophile_hugs@eml.cc 2012-10-04 03:21:21 PDT ---
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: -------
October 04, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8751



--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-10-04 05:27:35 PDT ---
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: -------
October 04, 2012
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


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-04 06:24:42 PDT ---
(In reply to comment #1)
> 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: -------
October 04, 2012
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


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2012-10-04 07:22:06 PDT ---
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: -------
October 04, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8751



--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2012-10-04 07:23:06 PDT ---
https://github.com/D-Programming-Language/dmd/pull/1161(In reply to comment #2)
> 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: -------
October 09, 2012
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


--- Comment #5 from yebblies <yebblies@gmail.com> 2012-10-10 02:32:00 EST ---
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: -------
October 09, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8751



--- Comment #6 from bearophile_hugs@eml.cc 2012-10-09 10:04:36 PDT ---
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: -------
October 10, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8751



--- Comment #7 from bearophile_hugs@eml.cc 2012-10-10 04:22:47 PDT ---
(In reply to comment #6)
> 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: -------