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-Candidate]: type_str(self) property in slithir/operations/unary.py not returning str #1849

Closed
DarrenChangJR opened this issue Apr 19, 2023 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@DarrenChangJR
Copy link
Contributor

Describe the issue:

    @property
    def type_str(self):
        return self._type.value

    def __str__(self):
        return f"{self.lvalue} = {self.type_str} {self.rvalue} "

type_str always returns 0 and 1 in place of "!" and "~" respectively. Is this intended behaviour?
If not, I will issue a pull request with below changes

    @property
    def type_str(self) -> str:
        return str(self._type)

Code example to reproduce the issue:

contract UnaryOperations {
uint256 public a = 10;
bool public b = true;

function executeUnaryOperations() public {
    a = -a; // Negation
    b = !b; // Logical negation
    a++; // Post-increment
    --a; // Pre-decrement
    a = ~a; // Bitwise negation
    a = +a; // Unary plus
}

}

Version:

0.9.3

Relevant log output:

No response

@DarrenChangJR DarrenChangJR added the bug-candidate Bugs reports that are not yet confirmed label Apr 19, 2023
@0xalpharush
Copy link
Contributor

@DarrenChangJR You're welcome to submit this patch as it should return a string.

@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 May 15, 2023
DarrenChangJR added a commit to DarrenChangJR/slither that referenced this issue May 15, 2023
montyly added a commit that referenced this issue May 15, 2023
Fix issue #1849: type_str not returning str
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
Projects
None yet
Development

No branches or pull requests

2 participants