Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd error span with invalid float #52

Open
CAD97 opened this issue Aug 13, 2022 · 4 comments
Open

Odd error span with invalid float #52

CAD97 opened this issue Aug 13, 2022 · 4 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@CAD97
Copy link
Contributor

CAD97 commented Aug 13, 2022

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
Copy link
Contributor Author

CAD97 commented Aug 13, 2022

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

@zkat zkat added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Aug 14, 2022
@zkat
Copy link
Member

zkat commented Aug 14, 2022

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

@CAD97
Copy link
Contributor Author

CAD97 commented Aug 14, 2022

Honestly I don't either.

@to-json
Copy link

to-json commented Mar 31, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants