You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Motivation
Users will create libraries for SimplicityHL with specific functions. However, depending on the version of SimplicityHL, they would likely want to rewrite some functions with the additional functionality added in new releases. So we can create tooling for convenient usage of libraries to filter function versions in the same file.
Describe the feature
We suggest adding a #[cfg(simc "...")] attribute before a function definition to show the compiler when that specific function version should be used.
#[cfg(simc "<0.7.0")]
pub fn verify_sig(...) {
// old logic of function
}
#[cfg(simc ">=0.7.0")]
pub fn verify_sig(...) {
// new logic of function
}
Implementation Plan
Parser Update: Add a chumsky combinator to parse the #[cfg(simc("..."))] attribute.
Evaluation: Extract the SemVer string and evaluate it against the current compiler version using crate::version::VersionRequirement logic Versioning #263 .
AST Pruning: If the version check fails, intercept the parser using .validate() and safely drop the item (e.g., mapping it to a dummy Item::Module).
Safety: Because the unsupported function is pruned during parsing, the semantic analyzer never sees it. This guarantees that older compilers will not throw Type Error or Redefined Function errors when they encounter new code they don't understand, provided the attribute filters it out.
Project
compiler
Describe the feature
Motivation
Users will create libraries for SimplicityHL with specific functions. However, depending on the version of SimplicityHL, they would likely want to rewrite some functions with the additional functionality added in new releases. So we can create tooling for convenient usage of libraries to filter function versions in the same file.
Describe the feature
We suggest adding a
#[cfg(simc "...")]attribute before a function definition to show the compiler when that specific function version should be used.Implementation Plan
Type ErrororRedefined Functionerrors when they encounter new code they don't understand, provided the attribute filters it out.