Skip to content

#7985: refuse an argument that is not a boolean in %b - #8014

Merged
yegor256 merged 1 commit into
masterfrom
7985
Aug 31, 2026
Merged

#7985: refuse an argument that is not a boolean in %b#8014
yegor256 merged 1 commit into
masterfrom
7985

Conversation

@yegor256

@yegor256 yegor256 commented Aug 31, 2026

Copy link
Copy Markdown
Member

Closes #7985.

%b read the bytes of its argument and printed true only for 01-, so everything else came out as false:

"%b".printf (* "x")   -> false
"%b".printf (* 0)     -> false

which states something about a string and a number that is not so. It accepts the bytes of true and false now and terminates on anything else, naming the argument, the way %s and %d refuse what they cannot convert.

Two tests cover it. They recover from the termination rather than declaring it with -->, for the reason the file's own header already gives about %f: a returned text of more than one byte fails to dataize as a boolean exactly as a termination does, so a --> test would have passed against master too. recovered gives the assertion something to compare, and against master it would come back "false" rather than "stopped".

The header gains a paragraph on what %b now refuses, and on the other face of the same coin the file already documents: a one-character text of U+0000 or U+0001 has the bytes of a boolean and is still accepted.

TestEOstring is green (418 tests) on a local mvn clean test -pl :eo-runtime -Deo.deadline=3600, with both new tests among them.

Touches the same if chain as #7976 (PR #8015), so whichever lands second will want a rebase.

The conversion read the bytes of its argument and printed `true` only
for `01-`, so a text or a number came out as `false`, which says
something about them that is not so. It accepts the bytes of `true` and
`false` now and terminates on anything else, naming the argument. Two
tests recover from that termination, since a returned text of more than
one byte fails to dataize as a boolean exactly as a termination does and
a `-->` test would pass either way.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NxFBB1HWHS1xgdM6bT9Qvw
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

These counts changed in this branch,
while the lower each one of them, the better:

Metric master branch change
positive-tests 1808 1810 +2

They are defined in .github/workflows/counts.yml

@github-actions github-actions Bot added the counts Some counts changed in this PR label Aug 31, 2026
@yegor256
yegor256 marked this pull request as ready for review August 31, 2026 08:25
Copilot AI lite review requested due to automatic review settings August 31, 2026 08:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@yegor256
yegor256 merged commit e7a1b61 into master Aug 31, 2026
24 checks passed
@yegor256
yegor256 deleted the 7985 branch August 31, 2026 13:11
@0crat

0crat commented Sep 3, 2026

Copy link
Copy Markdown

@yegor256 Thanks for the contribution! You've earned +4 points for this: +16 as a basis; -8 for the lack of code review; -4 for too few (31) hits-of-code. Please, keep them coming. Your running score is +1690; don't forget to check your Zerocracy account too).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

counts Some counts changed in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

string.printf %b silently prints false for a non-boolean argument

4 participants