iarna-toml icon indicating copy to clipboard operation
iarna-toml copied to clipboard

Stringify produces invalid floating point number

Open martykube opened this issue 2 years ago • 0 comments

This example is for iarna-toml 2.2.5 and node v16.13.1.

const TOML = require('@iarna/toml')
undefined
> config = TOML.parse('[config]\nvalue=1e-11')
{ config: { value: 1e-11 } }
> TOML.stringify(config)
'[config]\nvalue = 1e-11.0\n'
> TOML.parse(TOML.stringify(config))
Uncaught:
TomlError: Unexpected character, expected only whitespace or comments till end of line at row 2, col 14, pos 23:
1: [config]
2> value = 1e-11.0
                ^
3: 


    at TOMLParser.parseWhitespaceToEOL (/root/mnt/fds-core-workflow/node_modules/@iarna/toml/lib/toml-parser.js:311:26)
    at TOMLParser.runOne (/root/mnt/fds-core-workflow/node_modules/@iarna/toml/lib/parser.js:64:30)
    at TOMLParser.goto (/root/mnt/fds-core-workflow/node_modules/@iarna/toml/lib/parser.js:87:17)
    at TOMLParser.recordAssignStatement (/root/mnt/fds-core-workflow/node_modules/@iarna/toml/lib/toml-parser.js:337:19)
    at TOMLParser.runOne (/root/mnt/fds-core-workflow/node_modules/@iarna/toml/lib/parser.js:64:30)
    at TOMLParser.returnNow (/root/mnt/fds-core-workflow/node_modules/@iarna/toml/lib/parser.js:107:17)
    at TOMLParser.recordAssignValue (/root/mnt/fds-core-workflow/node_modules/@iarna/toml/lib/toml-parser.js:380:19)
    at TOMLParser.runOne (/root/mnt/fds-core-workflow/node_modules/@iarna/toml/lib/parser.js:64:30)
    at TOMLParser.returnNow (/root/mnt/fds-core-workflow/node_modules/@iarna/toml/lib/parser.js:107:17)
    at TOMLParser.parseNumberExponent (/root/mnt/fds-core-workflow/node_modules/@iarna/toml/lib/toml-parser.js:903:21) {
  fromTOML: true,
  wrapped: null,
  line: 1,
  col: 13,
  pos: 23
}
> quit

martykube avatar Mar 15 '22 18:03 martykube