-
Notifications
You must be signed in to change notification settings - Fork 9
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
Inlay hints: attempt to index a nil value #81
Comments
What language are you writing and which language server are you using for the hints? Ps, I assume rust Can you give me a minimal replication file? |
And you assumed right
As for the minimal replication file, I will create an online repo for this project I'll keep you in touch tomorrow and give you the entire project so you don't have to deal with missing dependencies |
If you can create a really simple reproduction that would make it easier for me. I don't know if you can create a hello world-esque function that captures the error |
Sure I'll try some things and I'll get back to you |
I found something: use std::collections::HashMap;
#[derive(Debug)]
enum Error {
EmptyField(String),
MissingField(String),
}
trait EmptyStringValue {
///Return an error if the value is empty
fn try_get<'a>(&'a self, s: &str) -> Result<&'a str, Error>;
///Return an error if the value is empty
fn try_get_owned(&self, s: &str) -> Result<String, Error>;
}
impl EmptyStringValue for HashMap<String, String> {
fn try_get<'a>(&'a self, s: &str) -> Result<&'a str, Error> {
if let Some(x) = self.get(s) {
if !x.is_empty() {
Ok(x.as_str())
} else {
Err(Error::EmptyField(s.into()))
}
} else {
Err(Error::MissingField(s.into()))
}
}
fn try_get_owned(&self, s: &str) -> Result<String, Error> {
if let Some(x) = self.get(s) {
if !x.is_empty() {
Ok(x.into())
} else {
Err(Error::EmptyField(s.into()))
}
} else {
Err(Error::MissingField(s.into()))
}
}
}
fn main() -> Result<(), Error> {
println!("Hello, world!");
let h: HashMap<String, String> = HashMap::new();
let (a, b, c, d) = (
h.try_get("a")?,
h.try_get("b")?,
h.try_get("c")?,
h.try_get("d")?,
);
Ok(())
} Error can be triggered on line 46, right on the |
Can you test with the branch in the linked PR please @monheimx9 As far as the spacing goes, I know what the issue is, but i need to think about it a little bit more |
Hello tris :^)
Here's my report on an issue after the last plugin update (6772d3a)
It doesn't happen on every lines, I might be wrong but I think the error is triggered when there are more that two hint on the line, and they must be variable type hints, for some reason it's a method hint (i.e what the function is returning) it does not trigger the error
Example 1:
Example 2:
I'm using NVIM v0.10.1
My distribution is LazyVim
And here's my precognition config
This might be related, sometimes the length is correctly calculated, sometimes it isn't
Example 1 (Almost got it):
Example 2 (Got it perfectly):
Example 3 (Way off):
Example 4 (Got it perfectly):
I don't really understand how Neovim plugins are architectured so it's difficult for me to point you in the right direction, yet don't hesitate to ask for more informations if needed
In the meantime, I wish you an excellent day
The text was updated successfully, but these errors were encountered: