dlang-community / D-YAML

YAML parser and emitter for the D programming language
https://dlang-community.github.io/D-YAML/
Boost Software License 1.0
119 stars 37 forks source link

serializer fails to find an anchor name in some cases #244

Closed Herringway closed 5 years ago

Herringway commented 5 years ago

Anchor names must not be empty strings, but for some reason this document causes dyaml to generate some empty anchor names.

    auto node = Node([
        Node.Pair(
            Node(""),
            Node([
                Node([
                    Node.Pair(
                        Node("d"),
                        Node([
                            Node([
                                Node.Pair(
                                    Node("c"),
                                    Node("")
                                ),
                                Node.Pair(
                                    Node("b"),
                                    Node("")
                                ),
                                Node.Pair(
                                    Node(""),
                                    Node("")
                                )
                            ])
                        ])
                    ),
                ]),
                Node([
                    Node.Pair(
                        Node("d"),
                        Node([
                            Node(""),
                            Node(""),
                            Node([
                                Node.Pair(
                                    Node("c"),
                                    Node("")
                                ),
                                Node.Pair(
                                    Node("b"),
                                    Node("")
                                ),
                                Node.Pair(
                                    Node(""),
                                    Node("")
                                )
                            ])
                        ])
                    ),
                    Node.Pair(
                        Node("z"),
                        Node("")
                    ),
                    Node.Pair(
                        Node(""),
                        Node("")
                    )
                ]),
                Node("")
            ])
        ),
        Node.Pair(
            Node("g"),
            Node("")
        ),
        Node.Pair(
            Node("h"),
            Node("")
        ),
    ]);

    auto stream = appender!string();
    dumper().dump(stream, node);