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

AA cannot be deserialized if its key type is string-based enum #1660

Closed
tom-tan opened this Issue Jan 22, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@tom-tan
Contributor

tom-tan commented Jan 22, 2017

The following code throws ConvException at runtime but it should not.
I confirmed this issue on Linux 64bit systems with dmd master.

import vibe.data.json;

void main()
{
    enum Foo: string
    {
        Bar = "bar",
        Buzz = "buzz"
    }

    struct S {
        int[Foo] f;
    }

    auto json = Json.emptyObject;
    json["f"] = [Foo.Bar: Json(2000)];
    auto s = json.deserialize!(JsonSerializer, S);
    assert(s.f == [Foo.Bar: 2000]);
}

Expected: This code can be compiled and run successfully.

Actual: This code can be compiled successfully but it throws the following exception at runtime:

std.conv.ConvException@/home/tom-tan/.denv/versions/dmd-2.072.1/linux/bin64/../../src/phobos/std/conv.d(2475): Foo does not have a member named 'bar'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment