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

After code is corrected and saved, previous error/problem is still persistent #195

Open
wileycoleman opened this issue Mar 29, 2024 · 10 comments
Assignees
Labels

Comments

@wileycoleman
Copy link

wileycoleman commented Mar 29, 2024

Describe the bug
After correcting code to eliminate an error, and saving the fie, the previous problem and flagging of the problem does not go a way.

To Reproduce
Make a simple type error in any code. For example use "string" instead of String. Save the file and see the proper error message and red underlining appear. Now change the code from "string" to "String". Save the file. The error message and red underlining do not go away. Close VScode and re-open it. The error message and underlining finally go away.

Expected behavior
Once error is corrected and file is saved, the red underlining and error messages should go away.

Piece of Code
see screenshot

Screenshots
Screenshot from 2024-03-28 20-57-44

Desktop (please complete the following information):

  • OS: Ubuntu 22.04 LTS
  • Crystal version: 1.11.2
  • This plugin version: 0.9.3
  • VS Code version: 1.87.2

Additional context
Add any other context about the problem here.

@wileycoleman wileycoleman changed the title After code is corrected and saved, previous error/problem is stll persistent After code is corrected and saved, previous error/problem is still persistent Mar 29, 2024
@nobodywasishere
Copy link
Member

Can you post the full output of the Crystal output channel?

@wileycoleman
Copy link
Author

The output tab is blank.

@nobodywasishere
Copy link
Member

You need to select "Crystal" from the dropdown at the top right of the panel

@wileycoleman
Copy link
Author

[Crystal] extension loaded
[Hover] getting context...
[Dependencies] epub_reader $ /usr/bin/crystal tool dependencies /home/cynthia/projects/crystal/epub_reader/src/epub_reader.cr -f flat --no-color
[Hover] error: undefined
[Hover] getting context...
[Dependencies] epub_reader $ /usr/bin/crystal tool dependencies /home/cynthia/projects/crystal/epub_reader/src/epub_reader.cr -f flat --no-color
[Hover] error: undefined
[Dependencies] epub_reader $ /usr/bin/crystal tool dependencies /home/cynthia/projects/crystal/epub_reader/src/epub_reader.cr -f flat --no-color
[Dependencies] error: In src/epub_reader.cr:1:24

1 | def testing_ext(file : string)
^
Error: unexpected token: "string"

[Problems] (epub_reader) $ /usr/bin/crystal build src/epub_reader.cr --no-debug --no-color --no-codegen --error-trace -f json -o /dev/null
[Problems] Error: [{"file":"/home/cynthia/projects/crystal/epub_reader/src/epub_reader.cr","line":1,"column":24,"size":null,"message":"unexpected token: "string""}]

[Hover] getting context...
[Dependencies] epub_reader $ /usr/bin/crystal tool dependencies /home/cynthia/projects/crystal/epub_reader/src/epub_reader.cr -f flat --no-color
[Dependencies] error: In src/epub_reader.cr:1:24

1 | def testing_ext(file : string)
^
Error: unexpected token: "string"

[Hover] error: undefined
[Problems] (epub_reader) $ /usr/bin/crystal build src/epub_reader.cr --no-debug --no-color --no-codegen --error-trace -f json -o /dev/null
[Problems] Error: [{"file":"/home/cynthia/projects/crystal/epub_reader/src/epub_reader.cr","line":1,"column":24,"size":null,"message":"unexpected token: "string""}]

[Hover] getting context...
[Dependencies] epub_reader $ /usr/bin/crystal tool dependencies /home/cynthia/projects/crystal/epub_reader/src/epub_reader.cr -f flat --no-color
[Dependencies] error: In src/epub_reader.cr:1:24

1 | def testing_ext(file : string)
^
Error: unexpected token: "string"

[Hover] error: undefined
[Problems] (epub_reader) $ /usr/bin/crystal build src/epub_reader.cr --no-debug --no-color --no-codegen --error-trace -f json -o /dev/null
[Problems] Error: [{"file":"/home/cynthia/projects/crystal/epub_reader/src/epub_reader.cr","line":1,"column":24,"size":null,"message":"unexpected token: "string""}]

[Hover] getting context...
[Dependencies] epub_reader $ /usr/bin/crystal tool dependencies /home/cynthia/projects/crystal/epub_reader/src/epub_reader.cr -f flat --no-color
[Dependencies] error: In src/epub_reader.cr:1:24

1 | def testing_ext(file : string)
^
Error: unexpected token: "string"

[Hover] error: undefined
[Problems] (epub_reader) $ /usr/bin/crystal build src/epub_reader.cr --no-debug --no-color --no-codegen --error-trace -f json -o /dev/null
[Problems] Error: [{"file":"/home/cynthia/projects/crystal/epub_reader/src/epub_reader.cr","line":1,"column":24,"size":null,"message":"unexpected token: "string""}]

[Dependencies] epub_reader $ /usr/bin/crystal tool dependencies /home/cynthia/projects/crystal/epub_reader/src/epub_reader.cr -f flat --no-color
[Hover] getting context...
[Dependencies] epub_reader $ /usr/bin/crystal tool dependencies /home/cynthia/projects/crystal/epub_reader/src/epub_reader.cr -f flat --no-color
[Hover] error: undefined

@wileycoleman
Copy link
Author

The above is from changing "String" to "string" then back. (saving file in between actions.)

@nobodywasishere
Copy link
Member

Thank you. In the meantime for things to work you can disable a lot of the features to just use snippets and syntax highlighting. Check this repo's README for more info

@nobodywasishere
Copy link
Member

nobodywasishere commented Jun 11, 2024

I've also run into some weird ghosting with Crystal sometimes recently. Does it still happen if you try building from the command line? crystal clear_cache may help.

@gregawoods
Copy link

Came here to report the same thing. I had a syntax error in a function definition (space required before colon in type restriction), fixed the problem, and the error hasn't gone away.

@nobodywasishere
Copy link
Member

@gregawoods If there are other problems in the file or potentially the workspace, the error might not go away until all them are resolved. A few questions to help diagnose:

  • What OS are you using?
  • What VSCode / extension versions are you using?
  • What shows up in the Crystal output channel when you save this file?

You can also try deleting the cache for this project (~/.cache/crystal-name-of-project on linux/macos) and reloading vscode to see if the error shows up still.

@gregawoods
Copy link

  • macOS 15.0.1
  • VSCode 1.94.0
  • Extension 0.9.6

Here's the console output. The actions I took here are: Intentionally introduce a syntax error, hit save, fix the error, hit save again.

[Dependencies] hello_crystal $ /Users/gregwoods/.asdf/shims/crystal tool dependencies /Users/gregwoods/Source/gregawoods/hello_crystal/src/hello_crystal.cr -f flat --no-color 
[Dependencies] error: In src/hello_crystal.cr:5:27

 5 | def self.say_hello(name :String)
                             ^
Error: space required after colon in type restriction

[Problems] (hello_crystal) $ /Users/gregwoods/.asdf/shims/crystal build src/hello_crystal.cr --no-debug --no-color --no-codegen --error-trace -f json -o /dev/null 
[Problems] Error: [{"file":"/Users/gregwoods/Source/gregawoods/hello_crystal/src/hello_crystal.cr","line":5,"column":27,"size":null,"message":"space required after colon in type restriction"}]

[Dependencies] hello_crystal $ /Users/gregwoods/.asdf/shims/crystal tool dependencies /Users/gregwoods/Source/gregawoods/hello_crystal/src/hello_crystal.cr -f flat --no-color 

Now, I've been playing around with the settings.json. I set both crystal-lang.hover and crystal-lang.dependencies to false and set crystal-lang.main to my main file, and now it's working properly again. I do not know if that is a permanent fix, or maybe I just kicked a cache somewhere by doing that, but either way things seem fairly happy right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants