This code currently compiles:
int bar();
@bar() void foo(){}
But this gives an error, as expected:
int bar();
@bar() void foo(){}
pragma(msg, __traits(getAttributes, foo));
I would expect the first example to give an error too. Is the
current behavior deliberate or is it a DMD bug?
On Sunday, 24 February 2013 at 16:04:19 UTC, jerro wrote:
This code currently compiles:
int bar();
@bar() void foo(){}
But this gives an error, as expected:
int bar();
@bar() void foo(){}
pragma(msg, __traits(getAttributes, foo));
I would expect the first example to give an error too. Is the
Why the fist is wrong? It is a call expression which is
acceptable according to the UDA grammar.
I'm not saying the syntax in the first example is, or should be,
invalid.
The reason the second
does not compile is because the statement is evaluated at CT,
and
interpreter cannot evaluate
On Sunday, 24 February 2013 at 16:36:05 UTC, jerro wrote:
The reason the second
does not compile is because the statement is evaluated at CT,
and
interpreter cannot evaluate call without source, like a regular
explicit call.
I know that, the thing is that it will give this error every
time
extern(C) int bar();
@bar() void foo(){}
//pragma(msg, __traits(getAttributes, foo));
void main()
{
auto x = __traits(getAttributes, foo)[0];
}
is compilable and runnable when linker knows where bar() is.
So this is actually supposed to work? The documentation says:
User Defined
On Sun, 24 Feb 2013 13:03:26 -0500, jerro a...@a.com wrote:
extern(C) int bar();
@bar() void foo(){}
//pragma(msg, __traits(getAttributes, foo));
void main()
{
auto x = __traits(getAttributes, foo)[0];
}
is compilable and runnable when linker knows where bar() is.
So this is actually
On Sunday, 24 February 2013 at 18:03:29 UTC, jerro wrote:
extern(C) int bar();
@bar() void foo(){}
//pragma(msg, __traits(getAttributes, foo));
void main()
{
auto x = __traits(getAttributes, foo)[0];
}
is compilable and runnable when linker knows where bar() is.
So this is actually
On 02/24/2013 05:04 PM, jerro wrote:
This code currently compiles:
int bar();
@bar() void foo(){}
But this gives an error, as expected:
int bar();
@bar() void foo(){}
pragma(msg, __traits(getAttributes, foo));
I would expect the first example to give an error too. Is the current
behavior
On 02/24/2013 08:19 PM, Timon Gehr wrote:
On 02/24/2013 05:04 PM, jerro wrote:
This code currently compiles:
int bar();
@bar() void foo(){}
But this gives an error, as expected:
int bar();
@bar() void foo(){}
pragma(msg, __traits(getAttributes, foo));
I would expect the first example to