kdl-rs
kdl-rs copied to clipboard
Odd error span with invalid float
fn main() {
let test = r#"
// Nodes can be separated into multiple lines
title \
"Some title"
// Files must be utf8 encoded!
smile "๐"
// Instead of anonymous nodes, nodes and properties can be wrapped
// in "" for arbitrary node names.
"!@#$@$%Q#$%~@!40" "1.2.3" "!!!!!"=true
// The following is a legal bare identifier:
foo123~!@#$%^&*.:'|?+ "weeee"
// And you can also use unicode!
ใใผใใใๅๅ="โ(๏พใฎ๏พโ)"
// kdl specifically allows properties and values to be
// interspersed with each other, much like CLI commands.
foo bar=true "baz" quux=false 1 2 3.
"#;
let err: kdl::KdlError = test.parse::<kdl::KdlDocument>().unwrap_err();
println!("{:?}", miette::Report::from(err));
}
ร Expected valid value.
โญโ[21:1]
21 โ // interspersed with each other, much like CLI commands.
22 โ foo bar=true "baz" quux=false 1 2 3.
ยท โโฌ
ยท โฐโโ invalid float
โฐโโโโ
help: Floating point numbers must be base 10, and have numbers after the decimal point.
According to my twitter feed, you should be using nom-locate and nom-supreme to build nom parsers which capture good error reporting information.
I have no idea what's even going on here. Some help would be super welcome.
Honestly I don't either.
Are y'all still able to reproduce? My guess had to do with SourceSpan being a (codepoint|character|byte)wise offset, which would be a Miette thing, but, I actually get the right span (560) when I run it (MacOS Ventura, latest miette and kdl-rs)