kdl-rs icon indicating copy to clipboard operation
kdl-rs copied to clipboard

Odd error span with invalid float

Open CAD97 opened this issue 2 years ago โ€ข 4 comments

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.

CAD97 avatar Aug 13 '22 11:08 CAD97

According to my twitter feed, you should be using nom-locate and nom-supreme to build nom parsers which capture good error reporting information.

CAD97 avatar Aug 13 '22 11:08 CAD97

I have no idea what's even going on here. Some help would be super welcome.

zkat avatar Aug 14 '22 18:08 zkat

Honestly I don't either.

CAD97 avatar Aug 14 '22 19:08 CAD97

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)

to-json avatar Mar 31 '23 02:03 to-json