Nadrieril / dhall-rust

Maintainable configuration files, for Rust users
Other
303 stars 27 forks source link

generic error message for duplicate field: RecordTypeMergeRequiresRecordType with no line reference #228

Closed alefminus closed 2 years ago

alefminus commented 2 years ago

For example:

dhall <<< '{
 a = 1,
 a = 2
}'

gives

Use "dhall --explain" for detailed errors

Error: Invalid duplicate field: a

1│ {
2│  a = 1,
3│  a = 2
4│ }

(input):1:1

But with serde_dhall:

use serde::Deserialize;
use serde_dhall;

#[derive(Deserialize)]
struct Config {
    a: usize,
}

fn main() {
    let c: Config = match serde_dhall::from_file("config.dhall").parse() {
        Err(e) => {
            println!("{}", e);
            return;
        },
        Ok(c) => c,
    };
}

Running the debug build (cargo run) on the same config

Type error: error: RecordTypeMergeRequiresRecordType

Further testing shows this isn't dependent on the type at all - i.e. I could have

{
b = 1
b = 2
}
Nadrieril commented 2 years ago

Hi, thanks for reporting this! I've released the best fix I can do at the moment, in v0.11.1.