Skip to content

feat(format): %<name>/%{name} references at any position in a directive - #6

Merged
tannevaled merged 1 commit into
mainfrom
fix/named-refs-anywhere
Aug 15, 2026
Merged

tannevaled merged 1 commit into
mainfrom
fix/named-refs-anywhere

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

What

A %<name> reference was only recognised at the very start of a directive, so MRI-valid forms with the name after flags/width/precision failed with "malformed format string - %<" — e.g. %+15.5<foo>f and %+15<foo>.5f (only %<foo>+15.5f and %+<foo>15.5f parsed).

Fix

A unified consumeRef(s) resolves a %<name>/%{name} token wherever it appears — before or after the flags, between width and precision, and between precision and the verb — invoked from each of those points in parseFlagsWidthPrec. %{name} is self-terminating (rendered as the value's to_s with the parsed flags/width/precision, no conversion letter). Mixing a named reference with an unnumbered or numbered positional one raises MRI's ArgumentError.

Downstream, this lets go-embedded-ruby's core/kernel/sprintf "reference by name" specs (supports flags, width, precision and type, allows to place name in any position) pass.

Verification

  • go vet ./..., the full suite and the 100% merged-coverage gate stay green.
  • New oracle cases lock the name-in-any-position forms against MRI.

🤖 Generated with Claude Code

…directive

A %<name> reference was only recognised at the very start of a directive,
so MRI-valid forms with the name after flags/width/precision failed with
"malformed format string - %<" — e.g. %+15.5<foo>f and %+15<foo>.5f (only
%<foo>+15.5f and %+<foo>15.5f parsed).

A unified consumeRef(s) now resolves a %<name>/%{name} token wherever it
appears — before or after the flags, between width and precision, and
between precision and the verb — invoked from each of those points in
parseFlagsWidthPrec. %{name} is self-terminating (rendered as the value's
to_s with the parsed flags/width/precision, no conversion letter). Mixing a
named reference with an unnumbered or numbered positional one is MRI's
ArgumentError.

go vet, the full suite and the 100% merged-coverage gate stay green; new
oracle cases lock the name-in-any-position forms.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 4038d17 into main Aug 15, 2026
11 checks passed
@tannevaled
tannevaled deleted the fix/named-refs-anywhere branch August 15, 2026 19:53
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