Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better errors for bad indents #169

Merged
merged 2 commits into from
May 16, 2020
Merged

Better errors for bad indents #169

merged 2 commits into from
May 16, 2020

Conversation

eemeli
Copy link
Owner

@eemeli eemeli commented May 10, 2020

This replaces the single error "Document is not valid YAML (bad indentation?)" with three more specific ones:

  • "All collection items must start at the same column"
  • "A collection cannot be both a mapping and a sequence"
  • "Document contains trailing content not separated by a ... or --- line"

I've also recently added the following related errors:

  • "Block scalars must not be less indented than their first line"
  • "Block scalars must not be less indented than their explicit indentation indicator"
  • "Block scalars with more-indented leading empty lines must use an explicit indentation indicator"

Given all that, the CST parser should now far more rarely produce documents with more than one content node, and the AST doc.parse(cst) method could be modified to always set doc.contents to the first content node's value, rather than including all of them as an array in some cases.

These changes mean that invalid input is handled a little bit differently than before, including the CST that's produced from it. Where possible, the graph should now more closely resemble its intended form, rather than just breaking in two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant