Bug 8813 – Cannot define delegate with const/immutable/shared/inout attributes

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-10-13T11:05:38Z
Last change time
2024-12-13T18:01:40Z
Assigned to
No Owner
Creator
SHOO
Moved to GitHub: dmd#18474 →

Comments

Comment #0 by zan77137 — 2012-10-13T11:05:38Z
This code doesn't work: ----------------------- void main() { auto dg = delegate() const { }; // NG } ----------------------- And, I do not know whether a cause is the same as this problem... This code doesn't work, too. ----------------------- import std.traits; void main() { static assert(is(FunctionTypeOf!(void delegate() const) == const)); // NG alias void delegate() const DG; // OK static assert(is(FunctionTypeOf!DG == const)); // OK } -----------------------
Comment #1 by k.hara.pg — 2012-10-14T20:50:28Z
(In reply to comment #0) > This code doesn't work: > ----------------------- > void main() > { > auto dg = delegate() const { }; // NG > } > ----------------------- In current, the semantics about qualified nested function (==lambda literal) is not defined in language spec. Compiler assumes that the frame pointer of nested function is always mutable. > And, I do not know whether a cause is the same as this problem... This code > doesn't work, too. > ----------------------- > import std.traits; > void main() > { > static assert(is(FunctionTypeOf!(void delegate() const) == const)); // NG > > alias void delegate() const DG; // OK > static assert(is(FunctionTypeOf!DG == const)); // OK > } > ----------------------- This is a parser bug and a rest of issue 4838. I've separated it to bug 8822.
Comment #2 by robert.schadek — 2024-12-13T18:01:40Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18474 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB