Skip to content

Feature: Versioning #248

@Sdoba16

Description

@Sdoba16

Project

compiler

Motivation

  1. In the future, SimplicityHL will likely introduce non-backward-compatible changes.
  2. Even if the language syntax remains identical, the generated CMR might change across different SimplicityHL versions. If smart contract developers do not notice the compiler update, compiling new contracts that interact with older deployed contracts could result in locking user funds.
  3. Smart contract audits are inherently tied to specific compiler versions to guarantee complete security and deterministic compilation.

To solve these problems, we need to add strict, built-in compiler versioning to the head of every .simf file.

Describe the feature

Each .simf file must declare a compiler version requirement at the very top (e.g., simc ">=0.6.0").

This version will be parsed in a preprocessing step before the full AST is constructed. The compiler will scan from the top of the file, safely skipping comments. When it encounters the first actual code, it will check if it is a version directive. If the directive is missing, the compiler will throw an error message. If it is present, it will verify compatibility against the currently running compiler using standard SemVer rules. This step will be done for all dependencies.

Implementation plan:

  1. Update the lexer and parser to cleanly extract and read the version directive at the start of the file.
  2. Read the compiler's actual version from Cargo.toml at build time for comparisons.
  3. Throw precise semantic errors if there is a mismatch (e.g., clearly distinguishing between "Compiler too old" and "Contract too old").

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions