Skip to content

Emit warning on integer & floating-point overflow #661

@eemeli

Description

@eemeli

Very large and very small numbers cannot be exactly represented with a JS Number.

When parsing a YAML document with such values (e.g. 1e-400, 61e9540), we should emit a warning if we're representing them as a Number with lossy precision.

This would correspond to what we're already doing when parsing a mapping with a non-scalar key as an Object rather than a Map:

warn(
ctx.doc.options.logLevel,
`Keys with collection values will be stringified due to JS Object restrictions: ${jsonStr}. Set mapAsMap: true to use object keys.`
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions