-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
Problem specifying filename #91
Comments
The second argument of The solution is to use a different cache type. There's a function called Report::build(ReportKind::Error, "hello", err.span().start)
...
.print(sources([
("hello", Source::from(src)),
...
])) Alternatively you have For the record: I'm not particularly happy with this API generally, and I'd like to find the time to redesign it such that this sort of confusion happens less. |
Thanks for the quick answer! Haha the API itself isn't a problem just as long as it's easy to understand :) I tried your suggestion now but still having trouble... it's probably something stupid like a comma or something... fn report(self, src: &str) -> Self {
let result = self.clone().into_result();
if let Err(errs) = result {
for err in errs {
Report::build(ReportKind::Error, "clarity contract", err.span().start)
.with_code(3)
.with_message(err.to_string())
.with_label(
Label::new(err.span().into_range())
.with_message(err.reason().to_string())
.with_color(Color::Red),
)
.finish()
.print(sources([
("clarity contract", ariadne::Source::from(src))
]))
.unwrap();
}
}
self
}
Maybe worth mentioning that I'm lexing with Logos (which also has a |
The problem is that your span also needs to have a matching |
I had the same problem, can you update the documentation |
Update it in what respect? |
What would have helped me solve this myself is probably a "Specifying the filename" docs/wiki section or a simple example with the name "custom_filename.rs" or something similar that just makes it easier to find :) |
like what @cylewitruk has stated better documentation on anything that is unusual. I've been using your chumsky library as an extension of ariadne docs so you could pull some of examples from there |
I just specified it everywhere and it works. Added filename to label fn report(self, src: &str) -> Self {
let result = self.clone().into_result();
if let Err(errs) = result {
for err in errs {
Report::build(ReportKind::Error, "clarity contract", err.span().start)
.with_code(3)
.with_message(err.to_string())
.with_label(
Label::new(("clarity contact", err.span().into_range()))
.with_message(err.reason().to_string())
.with_color(Color::Red),
)
.finish()
.print(("clarity contract", ariadne::Source::from(src)))
.unwrap();
}
}
self
} |
Hi!
I'm trying to follow along with the provided examples and seem to be running into a problem when trying to specify the
src_id
(which I understand should be the filename).I'm currently getting the following result using
()
assrc_id
:Which is beautiful btw... but when I try to specify anything as
src_id
in thebuild
function I can't seem to get it to work. In the example in README.me it looks like I should simply be able to provide a string slice, but I'm getting the following error:I have tried both:
and
according to the examples...
The text was updated successfully, but these errors were encountered: