Skip to content

Commit

Permalink
Fix #35: Fails to compile when serializing CTFE-able fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-carlborg committed Nov 27, 2013
1 parent 78ec917 commit 6db4d34
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion orange/serialization/Serializer.d
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@ class Serializer
{
static if (m != nonSerializedField)
{
mixin(`alias getAttributes!(T.` ~ m ~ `) attrs;`);
mixin(`alias attrs = Attributes!(m, __traits(getAttributes, T.` ~ m ~ `));`);

static if (attrs.contains!(event))
__traits(getMember, value, m)();
Expand Down
15 changes: 15 additions & 0 deletions tests/NonMutable.d
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ class A
A a;
immutable int ptr = 3;

class CTFEFieldsIssue35
{
public immutable FIRST = 1;
public immutable SECOND = 1;
public bool someFlag;
}

unittest
{
archive = new XmlArchive!(char);
Expand Down Expand Up @@ -97,4 +104,12 @@ unittest
assert(a == aDeserialized);
};
};

describe("serializing object with CTFE fields") in {
it("should compile") in {
assert(__traits(compiles, {
serializer.serialize(new CTFEFieldsIssue35);
}));
};
};
}

0 comments on commit 6db4d34

Please sign in to comment.