This bounty is no longer available
Web3 DAO | Ethereum Foundation Logo

Version pragma does not disallow prefixing version ranges with comparison operators

Organization

Ethereum Foundation

Deadline

N/A

Status

ENDED


INSTRUCTIONS

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:

pragma solidity <0.8.17 - >0.8.20;