Bug 11772 – Can't call function with `inout` `delegate` as argument

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-19T06:38:31Z
Last change time
2024-12-13T18:15:20Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Denis Shelomovskii
Moved to GitHub: dmd#18741 →

Comments

Comment #0 by verylonglogin.reg — 2013-12-19T06:38:31Z
This code should compile: --- alias T = inout(int*) delegate(inout int*); void f(T) { } void main() { T del; f(del); // line 8 } --- main.d(8): Error: cannot implicitly convert expression (del) of type inout(int*) delegate(inout(int*)) to const(int*) delegate(const(int*)) --- In spite of the error `const(int*) delegate(const int*)` doesn't work either.
Comment #1 by dfj1esp02 — 2014-09-13T17:03:34Z
Another test case --- struct S { void bar(void delegate(inout int*) dg) inout { dg(null); } } void main() { import std.stdio; S s; immutable(S) s2; s2.bar((inout int* p) => writeln(p)); s.bar((inout int* p) => writeln(p)); } --- Error: inout method S.bar is not callable using a immutable object Error: inout method S.bar is not callable using a mutable object --- Works for function, but not for delegate.
Comment #2 by dfj1esp02 — 2014-09-13T17:35:04Z
void f(inout int*, inout(int)* delegate(inout int*)){} void g() { immutable int a; f(&a,x=>x); } --- Error: function f (inout(int*) _param_0, inout(int)* delegate(inout(int*)) _param_1) is not callable using argument types (immutable(int)*, void) --- Again works for function, but not for delegate.
Comment #3 by robert.schadek — 2024-12-13T18:15:20Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18741 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB