-
Notifications
You must be signed in to change notification settings - Fork 193
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
VSCode Solidity Extension Not Flagging Errors for Undefined Variables and Syntax Issues #424
Comments
@antoniordf can you provide a full file? I don't have any issues. |
Hi @juanfranblanco, thanks for getting back to me. After my initial message I noticed that prettier also stopped working and isn't formatting my code. I'm not sure if this is what you meant when you asked for a file, but please see below for all my solidity user settings: Here are some of the settings in settings.json: I hope this helps. |
Can you share a solidity file in your project? Or does this happen to any solidity file. |
I have done some checks on this previously and some more now, and the behaviour is weirder than I thought. Here are the checks I have done: So this seems like really weird behaviour to me. This means that I can solve my problem by simply creating a new project but instead of copying code over, I need to re-write everything from scratch - which will be a huge pain. I am sharing a WeTransfer link below with my whole project here so maybe you can spot what is going on (I cant attach the file here). It is a sample lending pool that I am writing to better understand how they are built. Its a simplified version and borrows a lot from protocols like AAVE. |
Hi, There were issues in your contract, as there were a few might prevent auto complete, linting , formatting (prettier) to work, etc: For example:
In here I removed You had other issues like:
which had += instead of a : |
Thanks for having a look @juanfranblanco. Yes, the issues with the code are because it was being changed when this issue came up and there were things that I was planning to change. In any case I guess I will manually re-write the code in another project to get over this. I found that there was someone else who had the same issue in the past, but I was not able to replicate his solution: In any case, thanks for the help! I really appreciate it. |
@antoniordf you should not need to rewrite the code, I just used the same you gave me. |
I understand that the issue is not related to the code per-se. It seems to be something related to vscode. When you discussed this issue with codeonblocks in the issue #274 above, the problem seemed to be with "solidity.packageDefaultDependenciesDirectory", however it is not clear to me what he did to solve it. But for some reason vscode is displaying a behaviour in my system such that if I start a new empty file and start typing solidity code, it seems to work fine. |
@antoniordf So if you use your zip package (the one you sent), does everything work? (Apart from the EthPool and Token pool files, etc). As a new project will use the default settings. |
Hi @juanfranblanco, I have just tried that. I downloaded the code base and opened it in a new fresh project. Unfortunately I have observed that the issue remains. I think this is an issue with some vscode configuration or with the configuration of the extension. What is perplexing to me is that if I open a project I wrote months ago, before this issue appeared, it works perfectly. But somehow this current project and every new one I start seems to have this issue. Its quite strange frankly. PS: Before when I said that simply re-typing the code into a fresh project solved the issue, I was wrong. Some 20 lines of code in, I noticed that the issue persists. |
Can you delete your settings here? https://code.visualstudio.com/docs/getstarted/settings#_settings-file-locations |
Hi @juanfranblanco , apologies for delay. Here are the videos from my old project which works fine: Screen.Recording.2023-09-07.at.14.24.19.movScreen.Recording.2023-09-07.at.14.26.00.movScreen.Recording.2023-09-07.at.14.33.06.movHere is the project with issues: Screen.Recording.2023-09-07.at.14.28.02.movScreen.Recording.2023-09-07.at.14.29.56.movScreen.Recording.2023-09-08.at.10.35.03.movShould I go ahead and delete the settings? |
Also experiencing this issue, and having the same very odd issues where I can type code from scratch on a new project and it works fine, but if I copy code from the existing project that has the issue, it refuses to highlight syntax errors etc. |
Did you check the settings and see if validation is enabled? |
Hi, everyone and @juanfranblanco.
I was wondering if there has been some breaking update to the extension. I woke up this morning and the extension isn't working. It does the code highlight and colouring but the linting is not working. I am purposefully writing incorrect code expecting to see warnings and errors in vscode and I get nothing. The code below is an example:
`
function deposit(address asset, uint256 _amount) external whenNotPaused nonReentrant {
`
I would expect vscode to highlight "Why is vscode not marking this line as an error????" and "var variable = boo;" and display warnings and errors. I would also expect it to flag the fact that I passed "amount" into the updateInterestRates function rather than "_amount". Again I get nothing.
I have tried:
Nothing is working. I get the following errors in the Output tab for "Solidity Language Server" every time I hover over the code:
[Error - 22:44:58] Notification handler 'workspace/didChangeConfiguration' failed with message: Unexpected end of JSON input [Error - 22:45:04] Request textDocument/hover failed. Message: Request textDocument/hover failed with message: Cannot read properties of null (reading 'replace') Code: -32603 [Error - 22:45:04] Request textDocument/hover failed. Message: Request textDocument/hover failed with message: Cannot read properties of null (reading 'replace') Code: -32603 [Error - 22:51:31] Request textDocument/hover failed.
I have also noticed that my settings.json in vscode ahs the format [{...}]. The object is contained inside an array. Is that usually how it is? Perhaos it could explain the "Unexpected end of JSON input" error?
I would appreciate any help please.
The text was updated successfully, but these errors were encountered: