Skip to content

fix: handle !!bool explicit tag in Load - #210

Draft
toddr-bot wants to merge 1 commit into
cpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-bool-tag
Draft

fix: handle !!bool explicit tag in Load#210
toddr-bot wants to merge 1 commit into
cpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-bool-tag

Conversation

@toddr-bot

@toddr-bot toddr-bot commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

What

The !!bool YAML 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 bool type_id produced by an explicit !!bool tag.
This meant !!bool true loaded as the string "true" instead of Perl's true value (1).

Other explicit type tags (!!int, !!float, !!null, !!str) all worked correctly — only !!bool was missing.

How

Added a handler for the bare "bool" type_id that delegates to syck_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

  • New test t/gh-bool-tag.t (29 tests): all YAML 1.1 boolean word variants, non-boolean fallback, mappings, sequences, both ImplicitTyping on and off
  • Full test suite passes

Quality Report

Changes: 3 files changed, 63 insertions(+)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan

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).
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

Successfully merging this pull request may close these issues.

1 participant