Skip to content

Support solc prerelease compilers (e.g. 0.9.0-pre.1) #8886

Todo

Description

@Amxx

The Solidity team publishes prerelease compilers in the official binary lists (0.8.31-pre.1, 0.8.35-pre.1, and now 0.9.0-pre.1) so that projects can test against upcoming releases. Hardhat 3 can't use them today: solidity: { version: "0.9.0-pre.1" } fails with HHE903: Solidity version 0.9.0-pre.1 is invalid or hasn't been released yet.

Use case: library maintainers (we're preparing OpenZeppelin Contracts v6 against Solidity 0.9) want to run their existing Hardhat build and test suite on a prerelease without vendoring a binary and wiring it through path.

Why it fails today, in three places:

  1. CompilerDownloader#getCompilerBuild / #shouldDownloadCompilerList drop every build with a prerelease field. In list.json a prerelease appears as version: "0.9.0", prerelease: "pre.1", so no configured string can select it.
  2. SolcConfigSelector uses semver without includePrerelease, so 0.9.0-pre.1 never satisfies a pragma like >=0.8.20, even though solc accepts it.
  3. fast-semver.parseVersion rejects -prerelease suffixes. It's used for feature gates (ARM64 build availability, --no-import-callback, solcjs wrapper, coverage instrumentation), which throw INVALID_SOLC_VERSION.

Proposed behaviour:

  • A prerelease is selected only when its full version is configured ("0.9.0-pre.1"). "0.9.0" still means the release, so nobody gets a prerelease by accident.
  • Pragma matching follows solc: a prerelease satisfies a range when solc would accept it, i.e. it ranks below its release (>=0.8.20 ✓, ^0.8.20 ✗, ^0.9.0 ✗, >=0.9.0 ✗).
  • Feature gates treat X.Y.Z-pre.N like X.Y.Z.

An implementation is up in #8887 (about 180 lines including tests).

Metadata

Metadata

Type

No type

Projects

  • Status
    Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions