Skip to content

fix: preserve plain-string semantics for %vd formatting #1162

Description

@fglock

Summary

%vd formats an ordinary dotted numeric string as a version vector instead of
as the string's character code points.

Reproducer

printf "%vd\n", "1.22.333";

Expected behavior

Perl 5.42 prints:

49.46.50.50.46.51.51.51

Each character in the plain string is formatted as a decimal code point.

Actual behavior

Both the JVM and interpreter backends print:

1.22.333

Scope confirmed during investigation

This is specifically a plain string that happens to match a dotted-numeric
shape. A true v-string is correctly rendered as 1.22.333 by both Perl and
PerlOnJava, while adding a nonnumeric suffix makes PerlOnJava use the normal
character-vector path:

printf "%vd\n", v1.22.333;    # expected and actual: 1.22.333
printf "%vd\n", "1.22.333x"; # expected and actual: 49.46.50.50.46.51.51.51.120

Likely cause

SprintfVectorFormatter currently treats every scalar whose string value
matches \\d+(\\.\\d+)* as a version vector. The formatter should use the
scalar's v-string/version representation, not infer version semantics from an
ordinary string's text.

Impact

Any code using %vd to serialize or inspect character data gets silently
incorrect output when the data is composed only of dot-separated digits. This
is particularly risky because the output is plausible-looking and no error is
raised.

Acceptance criteria

  • An ordinary string "1.22.333" formats as character code points with %vd.
  • A real v-string continues to format as 1.22.333.
  • Verify both JVM and interpreter backends.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions