Skip to content

#688: guard against nil format string in Sprintf#evaluate - #689

Open
SAY-5 wants to merge 1 commit into
yegor256:masterfrom
SAY-5:fix-sprintf-nil-format
Open

#688: guard against nil format string in Sprintf#evaluate#689
SAY-5 wants to merge 1 commit into
yegor256:masterfrom
SAY-5:fix-sprintf-nil-format

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jul 26, 2026

Copy link
Copy Markdown

Closes #688.

Factbase::Sprintf#evaluate read its first operand (the format string) with a bare [0], while every sibling operand already used the safe &.first. _values returns bare nil when the referenced property is absent from the fact, so (sprintf $missing_prop 'hi') raised NoMethodError: undefined method '[]' for nil, which the term dispatcher then reported as the misleading "Probably the term 'sprintf' is not defined".

This guards the format-string operand and returns nil for a missing property, matching how Env#evaluate was fixed in #666 for the same bug class (#655). Added a regression test.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@0crat

0crat commented Jul 26, 2026

Copy link
Copy Markdown

@SAY-5 It is not a good idea to name Git branches the way you named this one: "fix-sprintf-nil-format". You've earned -6 points. Next time, better give your branch the same name as the number of the ticket that you are solving. In this case, a perfect name, for example, would be "688". Your running score is +18; 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Factbase::Sprintf#evaluate crashes with misleading error when format-string operand is a missing property

2 participants