argotorg / argotorg/solidity

Version pragma does not disallow prefixing version ranges with comparison operators

Open
#13,920 5 comments 0 reactions 0 assignees View on GitHub
bug :bug: low effort low impact should have
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

### Description
`pragma solidity` allows version ranges (e.g. `0.8.17-0.8.20`) and using comparison operators before a single version (e.g. `<0.8.17` or `=0.8.20`). Unfortunately it looks like a combination of the two is also allowed, which makes no sense: `<0.8.17 - =0.8.20`.

In version ranges the operator is simply ignored and replaced with `>=` for the first component and `<=` for the second one: https://github.com/ethereum/solidity/blob/ddbef8f65092cd09422366881d0fc1dad5d4b64e/liblangutil/SemVerHandler.cpp#L209-L215

### How to reproduce
This pragma will match `0.8.17`, `0.8.18`, `0.8.19` and `0.8.20`:
```solidity
pragma solidity <0.8.17 - >0.8.20;
```

Contributor guide

Open the contributing guide

Research direction

Read liblangutil/SemVerHandler.cpp around lines 209-215, then reproduce the pragma example from the issue to observe how comparison operators are handled in ranges. Done means a version range prefixed with comparison operators is rejected rather than silently normalized and accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.