crytic / crytic/slither

[Bug]: Reference variable has type `None` when overriding a variable name

Open
#2,050 0 comments 0 reactions 0 assignees View on GitHub
bug ir
Dominant language
Python
Stars
6.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

### Describe the issue:

When we print IR for the following source code:
```
pragma solidity ^0.8.13;

struct A {
uint256 z;
}

contract MyTest {
A a;

function test() external {
uint a = a.z;
}
}
```

The generated IR does not correctly type the variable `REF_0` as `int`. Instead, it has the type `None`:
```
INFO:Printers:Contract MyTest
Function MyTest.test() (*)
Expression: a = a.z
IRs:
REF_0(None) -> a.z
a(uint256) := REF_0(None)
```

### Code example to reproduce the issue:
```
pragma solidity ^0.8.13;

struct A {
uint256 z;
}

contract MyTest {
A a;

function test() external {
uint a = a.z;
}
}
```
### Version:

0.9.6

### Relevant log output:

```shell
INFO:Printers:Contract MyTest
Function MyTest.test() (*)
Expression: a = a.z
IRs:
REF_0(None) -> a.z
a(uint256) := REF_0(None)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.