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

Date throws an incomplete datetime exception #19

Closed
arnau opened this issue Jul 14, 2019 · 2 comments
Closed

Date throws an incomplete datetime exception #19

arnau opened this issue Jul 14, 2019 · 2 comments

Comments

@arnau
Copy link

arnau commented Jul 14, 2019

Hi, depending on what comes after a date, it parses correctly or it raises and exception TomlError: Incomplete datetime.

Reproduction steps

const toml = require('@iarna/toml')

const case1 = 'foo = 2019-07-14'
const case2 = 'foo = 2019-07-14\nbar = "lorem"'
const case3 = 'foo = 2019-07-14\n\nbar = "lorem"'

toml.parse(case1) // works!
toml.parse(case2) // don't work :(
toml.parse(case3) // works!

The exception for case2:

> toml.parse(case2)
Thrown:
TomlError: Unexpected character, expected only whitespace or comments till end of line at row 2, col 1, pos 18:
1: foo = 2019-07-14
2> bar = "lorem"
   ^


    at TOMLParser.parseWhitespaceToEOL (/Users/arnau/kitchen/blog/node_modules/@iarna/toml/lib/toml-parser.js:311:26)
    at TOMLParser.runOne (/Users/arnau/kitchen/blog/node_modules/@iarna/toml/lib/parser.js:64:30)
    at TOMLParser.goto (/Users/arnau/kitchen/blog/node_modules/@iarna/toml/lib/parser.js:87:17)
    at TOMLParser.recordAssignStatement (/Users/arnau/kitchen/blog/node_modules/@iarna/toml/lib/toml-parser.js:337:19)
    at TOMLParser.runOne (/Users/arnau/kitchen/blog/node_modules/@iarna/toml/lib/parser.js:64:30)
    at TOMLParser.returnNow (/Users/arnau/kitchen/blog/node_modules/@iarna/toml/lib/parser.js:107:17)
    at TOMLParser.recordAssignValue (/Users/arnau/kitchen/blog/node_modules/@iarna/toml/lib/toml-parser.js:380:19)
    at TOMLParser.runOne (/Users/arnau/kitchen/blog/node_modules/@iarna/toml/lib/parser.js:64:30)
    at TOMLParser.parse (/Users/arnau/kitchen/blog/node_modules/@iarna/toml/lib/parser.js:45:22)
    at Object.parseString [as parse] (/Users/arnau/kitchen/blog/node_modules/@iarna/toml/parse-string.js:13:12) {
  name: 'TomlError',
  fromTOML: true,
  wrapped: null,
  line: 1,
  col: 0,
  pos: 18
}

Environment

OS: macos 10.14.5
nodejs: v12.6.0
npm: 6.9.0
@iarna/toml: 2.2.3

@iarna
Copy link
Owner

iarna commented Aug 19, 2019

Thank you! I'll take a look at this soon!

@fffact
Copy link

fffact commented Nov 8, 2019

i've hit this too, and found out that case2 works with a slight modification, namely inserting a single space after the date:

const case2PlusSpace = 'foo = 2019-07-14 \nbar = "lorem"'

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

No branches or pull requests

3 participants