Skip to content

Mapping key duplicates; contradictory position SPEC vs. test matrix #57

@rumcajs-github

Description

@rumcajs-github

There are some places in https://yaml.org/spec/1.2/spec.html regarding mapping key duplicates:

1.3
Technically, YAML therefore complies with the JSON spec, choosing to treat duplicates as an error.

3.2.1.
Mapping nodes are somewhat tricky because their keys are unordered and must be unique.

3.2.1.1.
Mapping
The content of a mapping node is an unordered set of key: value node pairs, with the restriction that each of the keys is unique.

3.2.1.3.
Since YAML mappings require key uniqueness, representations must include a mechanism for testing the equality of nodes. This is non-trivial since YAML allows various ways to format scalar content. For example, the integer eleven can be written as “0o13” (octal) or “0xB” (hexadecimal). If both notations are used as keys in the same mapping, only a YAML processor which recognizes integer formats would correctly flag the duplicate key as an error.

10.1.1.1.
Represents an associative container, where each key is unique in the association and mapped to exactly one value.

My understanding of above is: mapping key duplicate is an error.

On the other side there is a test for duplicates in the section VALID of YAML test matrix:
https://matrix.yaml.io/sheet/valid.html#2JQS

Depending on the real intetntion it should be clear specified:

  • key duplicate is an ERROR and the test should be moved to INVALID
    or
  • key duplicate is OK and the SPEC should be modified (above texts and precedence rules should be added)

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