Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
July 29, 2018 [Issue 19127] UDAs seem to be raw AST nodes rather than expressions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19127 | <dhasenan@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid, spec -- |
July 29, 2018 [Issue 19127] UDAs seem to be raw AST nodes rather than expressions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19127 Seb <greensunny12@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |greensunny12@gmail.com Hardware|x86_64 |All OS|Linux |All -- |
July 29, 2018 [Issue 19127] UDAs seem to be raw AST nodes rather than expressions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19127 --- Comment #1 from | <dhasenan@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; -- |
July 30, 2018 [Issue 19127] UDAs seem to be raw AST nodes rather than expressions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19127 --- Comment #2 from | <dhasenan@gmail.com> --- Correction: non-CTFEable expressions besides function calls without arguments cannot be used as UDAs. Some of my testing was incorrect. Had B4S1L3 on IRC been more professional or friendly, I might have seen that sooner. -- |
July 30, 2018 [Issue 19127] UDAs seem to be raw AST nodes rather than expressions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19127 --- Comment #3 from | <dhasenan@gmail.com> --- Oh hey, more fun: --- module test2; import std.stdio; struct S { this(int i) { writeln(i); } } size_t print(string s = "hello world") { writeln(s); return s.length; } size_t x(size_t i) { return i + 1; } struct A { static uint x; } string s = ""; int i; @(std.stdio) @(new Object) @(x(4)) @(S(1)) @(A.x) @(A.x++) @print int j; pragma(msg, __traits(getAttributes, j).stringof); --- With the pragma(msg), this compiles. Without, it doesn't. Weee! -- |
December 17, 2022 [Issue 19127] UDAs seem to be raw AST nodes rather than expressions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19127 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P2 -- |
May 03, 2023 [Issue 19127] UDAs seem to be raw AST nodes rather than expressions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19127 Nick Treleaven <nick@geany.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@geany.org --- Comment #4 from Nick Treleaven <nick@geany.org> --- > "User-Defined Attributes (UDA) are compile-time expressions that can be attached to a declaration." Fixed this wording in https://github.com/dlang/dlang.org/pull/3598. > This should be invalid: > struct jsonize { string name; } > @jsonize int i; > `jsonize` is a type, but it is used as an expression. We see how this misbehaves when we inspect it: > foreach (uda; __traits(getAttributes, i)) writeln(uda); > // Error: cannot pass type jsonize as a function argument It is actually correct, a UDA can be defined by a type name. And naturally you can't pass a type as a function argument. You can use it in declarations, scroll down to the getAttributes example: https://dlang.org/spec/attribute.html#uda The other behaviour is very weird for @print. Also non-compile-time expressions should definitely be disallowed. -- |
October 16, 2023 [Issue 19127] UDAs seem to be raw AST nodes rather than expressions | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19127 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |b2.temp@gmx.com --- Comment #5 from Basile-z <b2.temp@gmx.com> --- The specs have changed since. Neia, can you re-evluate the validity of your report ? -- |
Copyright © 1999-2021 by the D Language Foundation