Open
Description
Minimal example that illustrates the problem:
#[test]
fn test() {
#[derive(knuffel::Decode)]
struct Test {
#[knuffel(children(name = "sorts"))]
sort: Vec<ThisOrThat>
}
#[derive(knuffel::Decode)]
enum ThisOrThat {
This,
That,
}
let parsed = match knuffel::parse::<Test>("example.kdl", r#"
sorts
"#) {
Ok(parsed) => parsed,
Err(e) => {
panic!("{:?}", miette::Report::new(e))
},
};
}
And the error is:
Error:
× expected one of `this`, `that`
╰─▶ expected one of `this`, `that`
╭─[example.kdl:1:1]
1 │
2 │ sorts
· ──┬──
· ╰── invalid value
╰────
The underlying problem is that the token "sorts" that is used to indicate what set of children it is is also being used as the same node that is supposed to indicate which enum variant. So in order for this to parse, it would be necessary for the name of the list of children to be the same as one of the enum variants, because that same token is being used for both purposes.
Metadata
Assignees
Labels
No labels
Activity