Deno: TOML Parser throws SyntaxError when parsing a boolean property followed by a comment on the same line

Created on 1 Aug 2020  路  4Comments  路  Source: denoland/deno

I could not find an exact example of this in the TOML spec, but since comments are valid after other types of key-value pairs, I expected the same for booleans.

The stdlib's TOML parser fails to parse Example B in the following example:

import { parse } from "https://deno.land/std/encoding/toml.ts";

// Example A: This parses correctly
console.log(parse(`
does_this_work = true
`));

// Example B: TOML parser throws a SyntaxError
console.log(parse(`
does_this_also_work = false # im a comment
`));

Error thrown:

$ deno run issue.ts
{ does_this_work: true }
error: Uncaught SyntaxError: Invalid or unexpected token
    at Parser._parseData (toml.ts:260:17)
    at Parser._processDeclaration (toml.ts:192:24)
    at Parser._parseLines (toml.ts:367:25)
    at Parser.parse (toml.ts:416:10)
    at parse (toml.ts:596:33)
    at issue.ts:7:13

Example A parses correctly, yet, Example B throws an error.

Deno Version: 1.2.2

bug std

Most helpful comment

@lucacasonato Thanks! Ill get started on this issue.

All 4 comments

Are these issues up for grabs? I would love to try my hand at contributing to deno! @ry

Yup, pretty much all issues that don't have an assignee, an open PR, or a commenter that is working on a PR are up for grabs. If you wanna work on an issue just add a comment to the PR, so noone else starts works on the same issue 馃槃.

You can find contributing instructions (how to clone, build from source, style guide, ect) at https://deno.land/manual/contributing. Thanks!

@lucacasonato Thanks! Ill get started on this issue.

This issue seems to be resolved now, may it be closed?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

motss picture motss  路  3Comments

JosephAkayesi picture JosephAkayesi  路  3Comments

ry picture ry  路  3Comments

doutchnugget picture doutchnugget  路  3Comments

kitsonk picture kitsonk  路  3Comments