web3 icon indicating copy to clipboard operation
web3 copied to clipboard

When finding solidity version, appears to look at any version number

Open treeder opened this issue 4 years ago • 2 comments

eg:

// SPDX-License-Identifier: NONE
// File @openzeppelin/contracts/utils/introspection/[email protected]

// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

...

It tries to use solc 4.4.1.

treeder avatar Feb 09 '22 14:02 treeder

Was it already fixed? Because I want to fix if not

luizhenridev avatar Nov 04 '24 03:11 luizhenridev

I don't think it was fixed.

treeder avatar Nov 04 '24 20:11 treeder

I’d like to work on this issue because I’ve identified the root cause: the current SolidityVersion function scans the entire source code for any version-looking number, which makes it incorrectly pick up numbers in comments or file metadata (like OpenZeppelin v4.4.1) instead of the actual pragma solidity line.

I plan to fix it by updating SolidityVersion to parse only the pragma solidity statement, ignoring all comments and unrelated version numbers. This ensures the correct compiler version is detected every time. I’ll also update the test to verify that the function correctly ignores version numbers in comments and extracts the real pragma version.

I’m confident I’m the right person for this job because I’ve already reproduced the issue locally, tested the current behavior, and implemented a working approach to fix it. I understand the repository and Go module workflow, and I can deliver a clean, reliable solution that addresses the root cause.

Alishba-Malik avatar Sep 06 '25 22:09 Alishba-Malik

Pull requests are welcome!

treeder avatar Sep 09 '25 05:09 treeder