fktn-k / fkYAML

A C++ header-only YAML library
MIT License
67 stars 7 forks source link

Wrong parse result from single scalar document #406

Open fktn-k opened 1 week ago

fktn-k commented 1 week ago

Description

Parsing a YAML document which contains only one scalar produces a mapping with the scalar as a key to a null scalar, but the parse result must be a scalar.

Reproduction steps

Run the following code:

char input[] = “foo“;
auto n = fkyaml::node::deserialize(input);
auto scalar = n.get_value<std::string>(); // This line throws a fkyaml::type_error since n is a mapping.

Expected vs. actual results

The parse result must be a scalar, but is a mapping.

Minimal code example

See the reproduction steps.

Error messages

type_error: The node value is not a string. type=mapping

Compiler and operating system

GCC 11.4.0 on Ubuntu 22.04 LTS

Library version

develop HEAD

Validation

fktn-k commented 1 week ago

This bug was found when trying to reproduce the issue #405.