Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to serialize const classes to Bson #653

Closed
japplegame opened this issue May 8, 2014 · 3 comments
Closed

Unable to serialize const classes to Bson #653

japplegame opened this issue May 8, 2014 · 3 comments

Comments

@japplegame
Copy link
Contributor

import vibe.data.bson;

class Foo {
    int a;
    Bson toBson() const { return serializeToBson(["a": a]); }
    static Foo fromBson(Bson bson) { return new Foo; }
}

void main() { 
    const auto foo = new Foo;
    auto bson = serializeToBson(foo);
}
vibe\data\serialization.d(146): Error: function vibe.data.bson.BsonSerializer.writeValue!(Foo).writeValue (Foo value) is not callable using argument types (const(Foo))
@japplegame
Copy link
Contributor Author

Doesn't compile again. :(

s-ludwig added a commit that referenced this issue Jun 5, 2014
@s-ludwig
Copy link
Member

s-ludwig commented Jun 5, 2014

Turns out the unit test for this was flawed (copy/past error). I've fixed both, the test and the code again now. Sorry, that was definitely quite unfortunate. I had to revert the use of auto ref to make things compile on 2.064 and GDC/LDC and trusted the test.

@japplegame
Copy link
Contributor Author

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants