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

[Bug]: immutable-state detector incorrectly claims strings can be made immutable #1595

Closed
area opened this issue Jan 12, 2023 · 1 comment · Fixed by #1639
Closed

[Bug]: immutable-state detector incorrectly claims strings can be made immutable #1595

area opened this issue Jan 12, 2023 · 1 comment · Fixed by #1639
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@area
Copy link

area commented Jan 12, 2023

Describe the issue:

According to the solidity docs while strings can be declared constant, they can not be declared immutable at this time. This detector, however, asks for strings to be declared immutable as if they were supported. Doing so causes the solidity compilation to fail.

Code example to reproduce the issue:

pragma solidity 0.8.17;

contract X {
  bool public immutable boolVar;
  string public stringVar;


  constructor(bool _boolVar, string memory _stringVar) {
    boolVar = _boolVar;
    stringVar = _stringVar;
  }
}

Version:

0.9.2

Relevant log output:

No response

@area area added the bug-candidate Bugs reports that are not yet confirmed label Jan 12, 2023
@0xalpharush 0xalpharush added bug Something isn't working good first issue Good for newcomers and removed bug-candidate Bugs reports that are not yet confirmed labels Jan 12, 2023
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: immutable-state detector incorrectly claims strings can be made immutable [Bug]: immutable-state detector incorrectly claims strings can be made immutable Jan 12, 2023
@0xalpharush 0xalpharush added the help wanted Extra attention is needed label Jan 12, 2023
@0xalpharush
Copy link
Contributor

This wasn't accounted for when reusing the _valid_type helper function from the constant detector. Just need to filter out string types here

elif (
v in constructor_variables_written or v in variables_initialized
) and version.parse(self.compilation_unit.solc_version) >= version.parse(
"0.6.5"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants