fix: handle !!bool explicit tag in Load - #210
Draft
toddr-bot wants to merge 1 commit into
Draft
Conversation
The !!bool YAML tag was silently ignored — values like '!!bool true' loaded as the plain string 'true' instead of Perl's boolean true (1). The parser handler had cases for 'bool#yes' and 'bool#no' (produced by implicit typing), but no case for the bare 'bool' type_id produced by the explicit !!bool tag. Add a handler that delegates to syck_match_implicit() to resolve the value, matching the same set of boolean words (true/false/yes/no/on/off and case variants).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
!!boolYAML tag is now correctly interpreted as a boolean value during Load.Why
The parser handler recognized
bool#yes/bool#no(from implicit typing)but had no case for the bare
booltype_id produced by an explicit!!booltag.This meant
!!bool trueloaded as the string"true"instead of Perl's true value (1).Other explicit type tags (
!!int,!!float,!!null,!!str) all worked correctly — only!!boolwas missing.How
Added a handler for the bare
"bool"type_id that delegates tosyck_match_implicit()to resolve the value text against the YAML 1.1 boolean word set (true/false/yes/no/on/off and all case variants). Non-boolean values gracefully fall back to strings.Testing
t/gh-bool-tag.t(29 tests): all YAML 1.1 boolean word variants, non-boolean fallback, mappings, sequences, both ImplicitTyping on and offQuality Report
Changes: 3 files changed, 63 insertions(+)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan