Bug 18990 – Failing class instantiations ignored in UDAs
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2018-06-15T07:42:17Z
Last change time
2018-06-15T11:01:04Z
Assigned to
No Owner
Creator
Simen Kjaeraas
Comments
Comment #0 by simen.kjaras — 2018-06-15T07:42:17Z
This compiles without error:
struct Attr
{
A h;
}
@Attr(new A(3)) // Line 6
class A {}
static assert(!__traits(compiles, new A(3)));
Clearly, line 6 should fail, since new A(3) doesn't compile elsewhere.
This issue seems to cause problem with std.traits.getSymbolsByUDA:
import std.traits;
static assert(!getSymbolsByUDA!(mixin(__MODULE__), Attr).length);
static assert(hasUDA!(A, Attr));
clearly, if hasUDA is true, then getSymbolsByUDA should return that symbol, but it doesn't. This could be a separate issue, but I'm not sure.
Comment #1 by razvan.nitu1305 — 2018-06-15T10:49:46Z
What version of the compiler are you using? I tried compiling your example with git HEAD master and the result was:
test.d(6): Error: no constructor for `A`
Comment #2 by simen.kjaras — 2018-06-15T11:01:04Z
This was under 2.080.0, which I just realized isn't the newest. It's indeed fixed in 2.080.1. Sorry for the noise. :p