Giter Site home page Giter Site logo

Comments (6)

perlpunk avatar perlpunk commented on May 26, 2024 1

Yes, that's really an edge-case.
We came to the conclusion that a mapping starting on the --- line is actually allowed, that's why CXX2 is valid:

--- &anchor a: b

The question, though, is, what's the correct indendation for the following lines?
As far as I know that's hard (or impossible?) to tell from the spec.
There are three possibilities:

--- a: 1
b: 2

--- a: 1
 b: 2

--- a: 1
    b: 2

One could argue that the document-start has a "logical" indendation of -1, so the mapping would have an indendation of 0, so the first example seems valid.
While the third example looks nicer, because the indendation matches.

Our opinion is that, because of this, a parser doesn't have to allow (or even should not allow) these kind of mappings (or sequences), but we still included the test case with one line because that's clearly valid from the spec. We also would like to forbid it completely for YAML 1.3.

Some existing parsers don't allow it (like libyaml), some allow the first example (libsyck), some allow the third (js-yaml).

I agree that these kind of test cases should have explanations.

@flyx, @ingydotnet any more thoughts?

from yaml-test-suite.

flyx avatar flyx commented on May 26, 2024 1

Definitely disallowed in YAML 1.3. The 1.2 Spec is a bloody mess when it comes to directive end markers. For example, this is a valid document according to the productions:

---- a
- b

And it is equivalent to

- a
- b

However, I don't think any implementation supports that and I don't think this was intended. I would advice to agree that these edge cases are not properly covered by the spec and therefore we should drop both test cases, assuming that what is supported and what isn't is implementation-defined. This conforms to the current situation.

from yaml-test-suite.

eemeli avatar eemeli commented on May 26, 2024

Actually, the spec does imply that the indentation should be

--- a: 1
b: 2

That's based on Example 9.5, which contains this bit:

--- |
%!PS-Adobe-2.0

which is considered equivalent to:

---
!!str "%!PS-Adobe-2.0\n"

That would only be valid if ---[ \t]* would not be considered when determining the indentation, and if it's true for block scalars, it ought to be true for block collections.

Regarding dropping the tests, I agree that at least 9KBC could be dropped due to being considered implementation-specific behaviour, but I think CXX2 is actually fine as it is; by keeping the contents to a single line, the uncertainty about the indentation can be ignored.

from yaml-test-suite.

perlpunk avatar perlpunk commented on May 26, 2024

@eemeli yeah:
"Document nodes are indented as if they have a parent indented at -1 spaces. Since a node must be more indented than its parent node, this allows the document’s node to be indented at zero or more spaces."
http://yaml.org/spec/1.2/spec.html#id2800967 9.1.3. Bare Documents

from yaml-test-suite.

ingydotnet avatar ingydotnet commented on May 26, 2024

Here's the meta take on this:

  • The 1.2 spec has many flaws, inconsistencies and unintended consequences
  • It is too late to change the 1.2 spec.
  • We are working on the yaml-test-suite to be the source of truth (SoT) for all YAML and YAML spec versions.
  • This means the spec for 1.2 is not the ultimate SoT. It is a guide to make hard decisions which will become represented clearly in the test suite.
  • The same test can be tagged in different ways.
  • The test suite is a work in progress and still quite young.
  • We are simultaneously in the process of creating YAML 1.3 (which is mostly removing the inconsistencies in 1.2).

Regardless of how, the spec is interpreted, 9KBC and CXX2 were not meant to be valid in 1.2. They are failures in the spec. The correct thing to do here is to tag them as being such.

We have been thinking about tags for these situations. Ideas are: 1.2-unknown, 1.2-bad-spec, 1.2-pedantic.

from yaml-test-suite.

eemeli avatar eemeli commented on May 26, 2024

This was fixed by a2f4449.

from yaml-test-suite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.