Bug 8751 – Problem with pure inference of inner delegate

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-10-04T03:21:00Z
Last change time
2012-10-10T04:22:47Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-10-04T03:21:21Z
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.
Comment #1 by k.hara.pg — 2012-10-04T05:27:35Z
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 }
Comment #2 by andrej.mitrovich — 2012-10-04T06:24:42Z
(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?
Comment #3 by k.hara.pg — 2012-10-04T07:22:06Z
Comment #4 by k.hara.pg — 2012-10-04T07:23:06Z
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.
Comment #5 by yebblies — 2012-10-09T08:32:00Z
Comment #6 by bearophile_hugs — 2012-10-09T10:04:36Z
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
Comment #7 by bearophile_hugs — 2012-10-10T04:22:47Z
(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