Repository navigation
feat(slang): add a Solidity version setting - #787
Merged
Merged
Conversation
nebasuke
force-pushed
the
solidity-version-flag
branch
2 times, most recently
from
October 4, 2026 10:44
de38f2f to
713e3bb
Compare
nebasuke
added this pull request to stack #788
October 4, 2026 10:49
Coverage Summary
|
nebasuke
force-pushed
the
solidity-version-flag
branch
from
October 4, 2026 12:23
91a7a98 to
76d50c9
Compare
nebasuke
marked this pull request as ready for review
October 4, 2026 12:43
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Version-dependent analysis, EVM defaults, and metadata across both compilation interfaces warrant human validation.
Review effort: Balanced
Findings: None
What changed in this PR
Adds Solidity language-version selection to solx’s compilation pipeline, enabling Hardhat 3 integration.
Changes:
- Exposes version selection through CLI and standard JSON.
- Applies version-aware EVM defaults and records the chosen version in metadata.
- Adds tests and documentation for supported versions and mode restrictions.
| File | Description |
|---|---|
| solx/tests/data/standard_json_input/solidity_version.json | Adds supported-version input. |
| solx/tests/data/standard_json_input/solidity_version_unsupported.json | Adds unsupported-version input. |
| solx/tests/data/contracts/solidity/TransientStorage.sol | Provides version-gated syntax. |
| solx/tests/data/contracts/solidity/PinnedPragma.sol | Provides a pinned-pragma contract. |
| solx/tests/cli/solidity_version.rs | Tests selection, defaults, metadata, and restrictions. |
| solx/tests/cli/mod.rs | Registers version-option tests. |
| solx-tester/src/compilers/solidity/mod.rs | Updates input constructor calls. |
| solx-tester/src/compilers/input_ext.rs | Leaves version selection unset for existing helpers. |
| solx-standard-json/src/input/settings/mod.rs | Defines the optional version setting. |
| solx-standard-json/src/input/mod.rs | Passes version selection through constructors. |
| solx-slang/src/slang/mod.rs | Resolves language versions and EVM defaults. |
| solx-core/src/project/mod.rs | Carries the chosen version into CBOR metadata. |
| solx-core/src/project/contract/metadata.rs | Accepts the selected semantic version. |
| solx-core/src/compiler.rs | Connects selection to compilation and metadata. |
| solx-core/src/arguments.rs | Adds the CLI option and mode checks. |
| docs/src/user-guide/03-standard-json.md | Documents JSON selection and defaults. |
| docs/src/user-guide/02-command-line-interface.md | Documents CLI selection and defaults. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
nebasuke
force-pushed
the
solidity-version-flag
branch
from
October 4, 2026 18:24
efc4c78 to
d436b4f
Compare
hedgar2017
reviewed
Oct 4, 2026
hedgar2017
reviewed
Oct 4, 2026
hedgar2017
requested changes
Oct 4, 2026
hedgar2017
left a comment
Contributor
There was a problem hiding this comment.
Thanks! Mostly code shape stuff.
hedgar2017
approved these changes
Oct 5, 2026
hedgar2017
left a comment
Contributor
There was a problem hiding this comment.
Thanks! One nit left.
Slang compiled every source as its latest language version, so any file whose pragma excludes it, such as `pragma solidity 0.8.20;`, was rejected. `--solidity-version` and the solx-only `settings.solidityVersion` pick the version instead, which the Hardhat plugin can set per compilation job. The CBOR metadata records the version compiled as, while `--version` keeps reporting the latest one Slang supports. Without a version the latest is still used; inferring it from the pragmas replaces that default later.
Solidity versions before 0.8.25 default to an EVM version older than Cancun. With a selectable Solidity version, compiling one of those without an EVM version panicked; it now reports an error asking for Cancun or later.
Requiring an EVM version for Solidity versions before 0.8.25 only made users pass the Cancun fallback by hand, which yields the same analysis and bytecode. Picking it with a warning keeps pinned-pragma projects compiling, such as Hardhat ones that leave evmVersion unset, until solx targets the older EVM versions solc defaults to.
standard_json returned the version next to the output, so every early error return had to make one up, and both callers already stop on those errors. Writing it into settings.solidityVersion keeps the return type and leaves the version unset only where nothing reads it.
Any default solx could not convert fell back to Cancun, including one newer than Osaka. Slang already knows Amsterdam, so the first Solidity version defaulting to it would have compiled for Cancun under a warning calling Cancun the oldest supported version. It now panics instead, and a test resolves the default of every Solidity version Slang supports.
Only a build suffix was tested, while language_version strips a prerelease suffix such as solc nightlies carry too.
The project only reads the version itself, so both callers wrapped the resolved version in a solx_standard_json::Version whose long form nothing used.
A --solidity-version suffix longer than eight bytes is heap-allocated by semver behind an encoded pointer. Both CLI exits skip destructors, so LeakSanitizer reported it as a direct leak and failed the suffix tests.
…sion The default was always the language version's own, so passing it separately only enabled a contradictory pair in a test. CLI tests already cover the Cancun fallback, and every compile at the latest version goes through the expect, so the unit tests go. Public items now precede private ones, a rule CLAUDE.md now states.
One inherent impl block per type keeps the public API and its private helpers in one place; the CLAUDE.md layout rule now says so instead of permitting the split.
nebasuke
force-pushed
the
solidity-version-flag
branch
from
October 5, 2026 12:35
fc87878 to
a371743
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for
--solidity-versionand standard JSON settingsettings.solidityVersion. This enables Hardhat 3 plugin integration, see NomicFoundation/hardhat#8658.Claude summary
Adds
--solidity-versionand the solx-only standard JSON settingsettings.solidityVersion, which set the Solidity version Slang compiles the sources as, from 0.8.0 up to the latest one Slang supports.pragma soliditymust allow the chosen version, so a pinned pragma such aspragma solidity 0.8.20;compiles once that version is set.--versionreports the latest supported one.settings.solidityVersion, and--solidity-versionis rejected there, as--evm-versionis.