Bug 15824 – 'scope' attribute ignored when making an alias to a scope delegate

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-03-23T14:48:01Z
Last change time
2020-08-04T04:24:20Z
Assigned to
No Owner
Creator
Mathias Lang

Comments

Comment #0 by mathias.lang — 2016-03-23T14:48:01Z
The following code fails to compile: ``` alias scope void delegate() AltDg; void foo (AltDg dg) @nogc {} void main () @nogc { uint i; foo(() { i = 1; }); } ``` Error message: `foo.d(4): Error: function D main @nogc function allocates a closure with the GC` Using `void foo (scope AltDg dg) @nogc {}` works fine.
Comment #1 by code — 2017-05-23T21:53:27Z
As scope is a storage class, it cannot be part of a type or alias declaration, i.e. just like ref you can add it for parameters and unlike ref, scope can be used on variable declarations.
Comment #2 by code — 2017-05-23T21:54:27Z
It should possibly be made an error to declare such aliases.
Comment #3 by pro.mathias.lang — 2020-08-04T04:24:20Z