Skip to content

Allow a table header on the last line without a trailing newline - #68

Open
vtxe02023274 wants to merge 1 commit into
SamboyCoding:masterfrom
vtxe02023274:fix/table-header-at-eof
Open

vtxe02023274 wants to merge 1 commit into
SamboyCoding:masterfrom
vtxe02023274:fix/table-header-at-eof

Conversation

@vtxe02023274

Copy link
Copy Markdown

A table header on the last line of a file with no trailing newline throws TomlEndOfFileException:

[a]
b = 1
[a.c]
Tomlet.Exceptions.TomlEndOfFileException: Found unexpected EOF on line 3 when parsing TOML file

Key/value lines and [[array]] headers at the end of a file already parse without a newline; only ReadTableStatement requires one. This is toml-test's valid/table/no-eol-01.

The fix keeps the newline check when there is more input ([table] key = 1 still throws TomlMissingNewlineException) and accepts end of input after the header, an optional inline comment, or whitespace.

Tests: TableHeaderCanBeLastLineWithoutNewline (4 cases) and SubTableHeaderCanBeLastLineWithoutNewline fail before the change and pass after; TableHeaderFollowedByContentOnTheSameLineIsRejected passes on both. All 170 tests pass. Running the toml-test 1.0.0 files through TomlTestDecoder before and after, the only change is valid/table/no-eol-01 now passing.

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.

1 participant