Skip to content

format_compound_unit adds an extra unit to preformatted string numerators #1398

Open

Description

@nawaaaaaAaar

On unchanged upstream e2a1791, format_compound_unit("1 kg", "kilometer", denominator_unit="hour", locale="en") returns "1 kg kilometer per hour"; calling the same function without numerator_unit returns "1 kg per hour". The documented contract says a string value is preformatted and its corresponding unit argument is ignored. The compound-unit optimization bypasses that rule for denominator_value == 1 and a known compound unit. This affects callers that accept either numeric quantities or already-localized display strings while retaining unit metadata. Eighteen regression cases across en/fi/fr and long/short/narrow lengths reproduce the mismatch before a production-code change. The numeric fast path should remain intact, but preformatted strings should use the existing general path. Identified and tested with AI assistance; no personal review or provenance attestation by the account owner is asserted.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions