metals icon indicating copy to clipboard operation
metals copied to clipboard

"No Definition found for" symbol error without Metals log explanation

Open tribbloid opened this issue 1 year ago • 10 comments

Describe the bug

image

in this screenshot, metals show "no definition found" error, when a definition is clearly available

also Metals log doesn't show any attempt to find the definition, this shouldn't happen

Expected behavior

should show attempt to find the definition

Operating system

Linux

Editor/Extension

VS Code

Version of Metals

1.4.2

Extra context or search terms

No response

tribbloid avatar Dec 26 '24 00:12 tribbloid

Thanks for reporting! Do you see anything in .metals/reports that could point to an issue? We are doing some improvements around that might help in https://github.com/scalameta/metals/pull/7028

tgodzik avatar Dec 27 '24 14:12 tgodzik

I've been getting that today:

error id: WorkService#fetchData().
file://<WORKSPACE>WorkService.scala
empty definition using pc, found symbol in pc: WorkService#fetchData().
semanticdb not found
|empty definition using fallback
non-local guesses:
	 -

Document text:

Yet the Scala file below contains:

private def fetchData(

I recently renamed that symbol but everything is compiling as far as I can tell.

matthughes avatar Jan 23 '25 18:01 matthughes

If no semanticdb is present and pc is having issues maybe the code doesn't compile, but it's not obvious why. 🤔 Though since it's a local symbol it should be simple to find for the compiler. Any chance to get a reproduction?

It's possible that project the current module depends on is not compiling and because of that it's not being attempted?

You could try to turn on metals.verboseCompilation and check the logs if it's indeed compiling.

tgodzik avatar Jan 23 '25 19:01 tgodzik

@matthughes did it actually fail to find the definition or are just seeing an error report? I think it's a bug with reporting.

kasiaMarek avatar Jan 24 '25 09:01 kasiaMarek

I also got this after renaming a symbol in metals.log:

SEVERE: empty definition using pc, found symbol in pc: <none>. (full report at: ...

I need to delete .metals and .bloop to clean the err maybe semanticdb needs refresh after rename?

doofin avatar Feb 06 '25 16:02 doofin

@tgodzik thanks a lot! can't find the report file, presumably it was generated

ideally this should be automatically included in telemetry

tribbloid avatar Feb 06 '25 21:02 tribbloid

@doofin, if otherwise metals seems to work, you don't have to do anything. Maybe I should change it to warning, so it looks less important.

kasiaMarek avatar Feb 12 '25 13:02 kasiaMarek

Hi @kasiaMarek metals ide shows red underline for the symbol after renaming but sbt compile works, it's actually a bit annoying since I need to delete.metals and.bloop, etc and reimport project to make the errors go away, glad to contribute if I have more information

To reproduce: In any sbt project, rename a top-level object name, and the referenced site will be red underlined sometimes (half of the time)

doofin avatar Feb 12 '25 13:02 doofin

@doofin, is what you are talking about a duplicate of https://github.com/scalameta/metals/issues/6478? This seems to be a bloop issue, so switching to sbt as build server might be a temporary solution, until we figure out why this is happening.

kasiaMarek avatar Feb 12 '25 13:02 kasiaMarek

@doofin, is what you are talking about a duplicate of #6478? This seems to be a bloop issue, so switching to sbt as build server might be a temporary solution, until we figure out why this is happening.

thanks, it's the same issue

doofin avatar Feb 12 '25 13:02 doofin