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

VS Code Solidity extension: Highlight Only Uninitialized Immutable Variables and Constructor #542

Open
AbhinavMir opened this issue Feb 14, 2024 · 4 comments
Assignees
Labels
good-first-issue Good for newcomers status:ready This issue is ready to be worked on

Comments

@AbhinavMir
Copy link

In the Solidity extension, currently, when immutable state variables are not initialized, the entire contract is highlighted in red. This is not optimal for understanding the issue at hand. It would be more helpful if only the uninitialized immutable variables and the related constructor were highlighted.

Steps to Reproduce:

  1. Declare an immutable state variable in a Solidity contract.
  2. Create a constructor without initializing the immutable variable.

Expected: Highlighting of immutable variable and constructor to be have red squiggly lines.

Actual: Everything is red, making it hard to see which immutable variables are the problem.

image

@AbhinavMir
Copy link
Author

(Can take this up is this is an actual issue!)

@kanej
Copy link
Member

kanej commented Feb 14, 2024

This is a great suggestion for an improvement.

What is happening is that that solc is giving an error (solc 2658). The range that solc is giving in the source code is the entire contract:

image

With the extension we can manipulate that source range so that it is limited to the constructor, more specifically just to the constructor keyword.

The way this would be implemented is by providing a new CompilerDiagnistic for 2658. This diagnostic would provide no code actions but transform the solc error by constraining the source range by implementing fromHardhatCompilerError, and constraining to the constructor keyword. You can see a similar move here:

return attemptConstrainToFunctionName(document, error);

@kanej kanej added good-first-issue Good for newcomers status:ready This issue is ready to be worked on and removed status:triaging labels Feb 14, 2024
@AbhinavMir
Copy link
Author

AbhinavMir commented Feb 15, 2024

Thanks! I can implement this, but I'm taking a break till end of week. Could you assign it to me so I can keep a tab on it and close it this weekend?

@kanej
Copy link
Member

kanej commented Feb 15, 2024

Hey @AbhinavMir I have assigned it to you. Thanks and good luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good-first-issue Good for newcomers status:ready This issue is ready to be worked on
Projects
Status: Todo
Development

No branches or pull requests

2 participants