castwide / solargraph

A Ruby language server.
https://solargraph.org
MIT License
1.87k stars 154 forks source link

String inference not working sporadically #679

Open alexrecuenco opened 10 months ago

alexrecuenco commented 10 months ago

I was trying solargraph, and although on hover it tells me that x is a string, it is not providing method inference, however if I do b.x it does provide it

I tried in https://solargraph.org/demo


# This editor uses solargraph-rails to provide Ruby code completion.
# Code suggestions include the core Ruby library, local class and variable
# definitions, and hints from YARD documentation.
# Hit ctrl+space anywhere in code to get context-aware suggestions.

# Try entering `str.` and hitting ctrl+space to see String instance methods.

class A
  def x
    "-> { 3 }"
  end
end

b = A.new
x = b.x
b.x.ascii_only? # <-- provides type inference for b.x
x.#<ctrl+space> #... <-- doesn't provide inference of possible options for x (

Thank you for your time, I couldn't find any similar issue.

alexrecuenco commented 10 months ago

I tried later to change the x variable name to d and the inference was working again... I don't know what is going on