Skip to content
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.

toml-rs forbids empty keys, which are allowed by the spec #425

Closed
joelthelion opened this issue Apr 17, 2021 · 3 comments
Closed

toml-rs forbids empty keys, which are allowed by the spec #425

joelthelion opened this issue Apr 17, 2021 · 3 comments

Comments

@joelthelion
Copy link

The TOML spec says (https://toml.io/en/v1.0.0#keys):

A bare key must be non-empty, but an empty quoted key is allowed (though discouraged).

So I would expect the following program to work:

use toml;

fn main() {
    r#""" = 5"#.parse::<toml::Value>().unwrap();
}

But this is what I get:
thread 'main' panicked at 'called Result::unwrap()on anErr value: Error { inner: ErrorInner { kind: EmptyTableKey, line: Some(0), col: 0, at: Some(0), message: "", key: [] } }', src/main.rs:4:40

By comparison, python will happily run the following program:

import toml

print(toml.loads(""""" = 5"""))
@joelthelion
Copy link
Author

joelthelion commented Apr 17, 2021

I just noticed there is a fix in the following PR, but it was never merged: #373

@Kixunil
Copy link

Kixunil commented Jul 17, 2021

This was fixed, right?

@ehuss
Copy link
Collaborator

ehuss commented Jul 19, 2021

Yes, this has been fixed by #373.

@ehuss ehuss closed this as completed Jul 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants