Bug 17911 – Add { } block attributes for local variables

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-10-17T14:49:35Z
Last change time
2020-06-13T18:36:55Z
Assigned to
No Owner
Creator
Timoses

Comments

Comment #0 by timosesu — 2017-10-17T14:49:35Z
The example for user defined attributes (UDA) on https://dlang.org/spec/attribute.html#uda does not work: @(1) { @(2) int a; // has UDA's (1, 2) @("string") int b; // has UDA's (1, "string") } causes: src\app.d(59,5): Error: basic type expected, not { src\app.d(59,5): Error: no identifier for declarator _error_ The same is caused by @(1) {} DMD32 D Compiler v2.074.0
Comment #1 by bugzilla — 2018-05-17T04:31:32Z
Why is this marked as a regression? Which compiler version did it work on?
Comment #2 by slavo5150 — 2018-05-17T04:50:10Z
I cannot reproduce this in either Linux (2.080) or Windows (2.079). You can also see that it works fine at https://run.dlang.io/is/v6SW8Q Please reopen and supply a complete module with precise compiler flags to reproduce the symptoms if the problem persists.
Comment #3 by trikkuz — 2018-05-17T07:22:41Z
Probably this is the problem he found: https://run.dlang.io/is/zim8Z0
Comment #4 by timosesu — 2018-05-17T13:15:04Z
I apologize in case I have reported the bug incorrectly. Indeed, I mean Andrea Fontana's version. The following clarifies a bit more perhaps: ------------------------------------------------------ struct F { @(1) // works! { @(2) int a; // has UDA's (1, 2) @("string") int b; // has UDA's (1, "string") } } void func() { @(1) // compilation error { @(2) int a; // has UDA's (1, 2) @("string") int b; // has UDA's (1, "string") } } void main() { struct G { @(1) // works! { @(2) int a; // has UDA's (1, 2) @("string") int b; // has UDA's (1, "string") } } } ----------------------------------------------------- I'm not sure whether attribution of local variables makes any sense anyhow. Does it? If that were the case the error message coule be more descriptive.
Comment #5 by bugzilla — 2018-12-16T11:14:26Z
The { } attribute syntax is not supported for local variables: void bar() { const { int a = 3; } } It's never been supported, so it's not a regression. Marked as enhancement request.
Comment #6 by b2.temp — 2020-06-13T18:36:55Z
*** This issue has been marked as a duplicate of issue 11064 ***