[Issue 19127] UDAs seem to be raw AST nodes rather than expressions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 29 20:16:06 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19127

--- Comment #1 from | <dhasenan at gmail.com> ---
Other things you can use as UDAs:

* modules: @(std.stdio)
* packages: @(std)
* references to members: struct A { int i; } @(A.i)
* uint s; @(s++). This UDA changes every time you access it.
* @(new Object). Likewise.
* string str; @(str ~= "x"). Likewise.

The only thing that doesn't work is declarations, because that's forbidden by
the grammar. It seems like there's no special semantic analysis applied other
than recursing into child expressions.

Lowering should help:

@Something int x;

into

immutable __tmp = Something;
@__tmp int x;

--


More information about the Digitalmars-d-bugs mailing list