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

True and False boolean literals seem to be parsed as strings #196

Open
reivilibre opened this issue Mar 11, 2024 · 2 comments
Open

True and False boolean literals seem to be parsed as strings #196

reivilibre opened this issue Mar 11, 2024 · 2 comments

Comments

@reivilibre
Copy link

yaml-rust/src/yaml.rs

Lines 307 to 308 in da52a68

"true" => Yaml::Boolean(true),
"false" => Yaml::Boolean(false),

I am actually really struggling to understand the YAML 1.2 spec here, but I think it's saying that a parser can be in one of two modes: JSON schema tag resolution, or core schema tag resolution (with core seemingly being recommended as a default).
https://yaml.org/spec/1.2.2/#1022-tag-resolution

From my reading:

  • In the JSON schema tag resolution, True indeed should be interpreted as "True"; but
  • in the core schema tag resolution, True should be interpreted as true.

In any case, my colleagues used to YAML 1.1 were taken by surprise when True wasn't working for them. I am not sure what the right answer is here, but I suspect these boolean literals should still be treated as valid booleans.

@hoodie
Copy link
Contributor

hoodie commented Mar 31, 2024

AFAIK the yaml 1.2 spec is smaller and more strict than 1.1. That's why a number of different representations for true and false are now treated as strings (including yes and no). The reference you provide is really curious, I haven't found any reference about how to communicate to the parser which schema to follow. How would I mark a document/value to be understood as JSON schema tag resolution or core schema tag resolution?

@davvid
Copy link

davvid commented Mar 31, 2024

This repo is basically unmaintained. I would recommend moving this discussion to a new issue in https://github.com/Ethiraric/yaml-rust2 where it'll have a better chance of resulting in improvements.

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