Visitar URL original
Can't round-trip out-of-range floating point · Issue #737 · nodeca/js-yaml · GitHub
Skip to content

Can't round-trip out-of-range floating point #737

Closed

Description

@lionello

Describe the bug
When parsing a document with an unquoted string that "looks like" a number, the parser will use the float tag, even though the value cannot be represented by the JavaScript number and ends up getting stored a +Inf or -Inf.

To Reproduce
Steps to reproduce the behaviour:

> require("js-yaml").load("gitsha: 61e9540")
{ gitsha: Infinity }

Expected behaviour
Like some other YAML loaders (go-yaml comes to mind), an untagged, unquoted value should only be interpreted as a float if it can be safely stored as such in the native type.

Versions (please complete the following information):

  • NodeJS 24.12.0
  • js-yaml: 4.1.1

Additional context
The YAML 1.2 spec is pretty clear:

Some languages (such as Perl) provide only a "number" type that allows for both integer and floating-point values. A YAML [processor] may use such a type for floating-point numbers, as long as they round-trip properly.

Activity

  1. changed the title [-]Can't roundtrip out-of-range floating point[/-] [+]Can't round-trip out-of-range floating point[/+] on Feb 12, 2026
  2. added a commit that references this issue on May 9, 2026
    65d1380
  3. Jah-yee commented on May 9, 2026

    @Jah-yee
  4. added a commit that references this issue on May 11, 2026
    2083e32
  5. added a commit that references this issue on May 25, 2026
    ca571e3
  6. added this to the Next milestone on May 27, 2026
  7. added a commit that references this issue on May 31, 2026
    1f45644
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions