crytic / crytic/slither

[Bug]: Invalid type assigned to literals

Open
#1,688 1 comment 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:

It appears that IR considers literals as `uint256` or `int256` type, but they should be assigned the smallest possible type instead.

### Code example to reproduce the issue:

```solidity
function test5(uint40 x) external view returns (uint256 res) {
res = x * 50;
}
```

`50` should be `uint8`, but `ir.variable_right.type` returns `uint256`.

### Version:

0.9.2

### Relevant log output:

_No response_

Contributor guide

Open the contributing guide

Research direction

Use the supplied test5 Solidity example to reproduce the reported type on variable_right.type. Trace the IR type-inference path that assigns the literal's type, then verify that 50 is represented with the smallest possible type rather than uint256. Done means the example reports the expected literal type and a regression test covers it.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, solidity
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.