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

The Norway problem #66

Open
VPanteleev-S7 opened this issue Jan 25, 2025 · 4 comments
Open

The Norway problem #66

VPanteleev-S7 opened this issue Jan 25, 2025 · 4 comments

Comments

@VPanteleev-S7
Copy link
Contributor

D program:

import std.stdio;
import configy.read;

void main()
{
    struct C { string[] countries; }
    auto c = parseConfigFileSimple!C("test.yaml");
    writeln(c.get());
}

YAML:

countries:
  - UK
  - NO
  - US

Expected output:

C(["UK", "NO", "US"])

Actual output:

C(["UK", "false", "US"])

Because we know we're deserialising into a string, we should capture the original token and then parse that as needed depending on the desired type, instead of eagerly converting to bool and then stringifying it.

@Geod24
Copy link
Member

Geod24 commented Jan 25, 2025

Is it a D-YAML issue or a Configy issue ? Note that there is the (perhaps relevant) issue here: dlang-community/D-YAML#337

@VPanteleev-S7
Copy link
Contributor Author

Yes, D-YAML might be where the fix is needed. Not sure if any changes are needed in Configy or not.

@Herringway
Copy link
Member

Is it a D-YAML issue or a Configy issue ? Note that there is the (perhaps relevant) issue here: dlang-community/D-YAML#337

That issue is unlikely to change this situation by itself. It may be easier to work around this with the fix implemented, however.

dlang-community/D-YAML#110 is relevant. The YAML 1.1 spec defined yes/no and their various capitalizations as boolean values, so YAML 1.1 compliance requires that. YAML 1.2 dropped that requirement, however, so whenever that gets implemented, it will no longer be an issue by default.

Unfortunately, I haven't been able to make much progress on that in a while.

@VPanteleev-S7
Copy link
Contributor Author

If we want to be strictly compliant with YAML 1.1, then making so that trying to parse a boolean into a string would throw an error would also be OK, I think.

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

3 participants