ingydotnet / yaml-libyaml-pm

Perl Binding to libyaml
http://search.cpan.org/dist/YAML-LibYAML/
33 stars 37 forks source link

Support proper booleans on Perl 5.36+ #113

Closed leonerd closed 7 months ago

leonerd commented 8 months ago

Since Perl 5.36, we've been able to distinguish actual boolean values. It'd be great if YAML::XS emitted these distinctly.

Currently this gives disappointing results:

$ eachperl modversion YAML::XS
perl5.36.0: 0.88
perl5.38.0: 0.88
bleadperl: 0.88

$ eachperl -MYAML::XS -E 'say YAML::XS::Dump([1, "1", builtin::true])'

  --- perl5.36.0 --- 
Built-in function 'builtin::true' is experimental at -e line 1.
---
- 1
- '1'
- 1

  --- perl5.38.0 --- 
Built-in function 'builtin::true' is experimental at -e line 1.
---
- 1
- '1'
- 1

  --- bleadperl --- 
---
- 1
- '1'
- 1

I would love to have seen the output be:

---
- 1
- '1'
- true
leonerd commented 8 months ago

I couldn't work out how to run the tests from this repo, but find attached a patch against the actual YAML::XS module from CPAN, that implements core booleans. Tested on 5.36+ and also a 5.20 to demonstrate it doesn't break on older perls.

gh113.txt