Nadrieril / dhall-rust

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

home-anchored imports don't work #223

Closed s-zeng closed 2 years ago

s-zeng commented 2 years ago

Forwarded from https://github.com/s-zeng/dhall-python/issues/41

According to the dhall documentation, the dhall language supports home-anchored imports as shown in the following example. dhall-rust however seems to support only the relative and absolute imports, but not the home-anchored import.

> dhall <<< '~/test.dhall'
"hello"

> cat src/main.rs
fn main() {
    let str_a = "./test.dhall";
    let str_b = "~/test.dhall";
    let local_test = serde_dhall::from_str(str_a).parse::<String>();
    let home_test = serde_dhall::from_str(str_b).parse::<String>();
    println!("Local import: {:?}", local_test);
    println!("Home import: {:?}", home_test);
}

> cargo run
Local import: Ok("hello")
Home import: Err(Error(Dhall(Error { kind: Typecheck(TypeError { message: Custom("error: error\n --> <current file>:1:1\n  |\n1 | ~/test.dhall\n  | ^^^^^^^^^^^^ No such file or directory (os error 2)\n  |") }) })))

Tested with serde_dhall 0.10

Thank you @padhla for reporting