Add target-fork conditional compilation#1940
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
| \n### CI Failure Hints\n\nFailed jobs: `build`\n\nCopy-paste local triage:\n```bash\nmake check\nlake build\nFOUNDRY_PROFILE=difftest forge test -vv\n``` |
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.
Summary
Adds target-fork-aware conditional compilation for explicit intrinsic fallback paths.
The core design is a new pure expression form:
Both branches are typechecked and validated, but the compile driver specializes the compilation model using
--target-forkbefore intrinsic fork checks and Yul emission. This keeps intrinsic declarations strict: an Osaka intrinsic still hard-errors below Osaka unless it is in an unselected branch with an explicit fallback.Architecture
Expr.forkIfAtLeast required thenExpr elseExprfork_if_at_leastcompileSpecsWithOptionsbeforeensureIntrinsicForksAllowedforkIfAtLeastincompileExprThis intentionally avoids automatic intrinsic fallback metadata. The fallback remains visible in source, the intrinsic
min_forkremains meaningful, and consumers own the equivalence obligation between branches.Verification
lake build Compiler.CompileDriverTestlake build Compiler.MainTest Compiler.CompileDriverTest Compiler.Proofs.IRGeneration.IntrinsicProofs Contracts.Smokenpm run buildindocs-sitemake checkNote
Medium Risk
Changes compile-time fork specialization and intrinsic gating across the full compiler pipeline; incorrect branch selection or missed analysis cases could emit wrong Yul or weaken fork checks, though driver tests and explicit compileExpr rejection mitigate direct misuse.
Overview
Introduces
Expr.forkIfAtLeastand EDSLfork_if_at_least, so authors can pair a newer-fork intrinsic with an emulated fallback while both branches stay typechecked.compileSpecsWithOptionsnow runsspecializeForkSpecon specs using--target-forkbefore intrinsic fork checks and Yul emission: the unselected branch is erased, so only the chosen path is subject tomin_forkrules. DirectcompileExprstill errors on unresolvedforkIfAtLeastto keep Yul lowering fail-closed.The new constructor is wired through validation, usage analysis, logical purity, ECM collection, macro translation, docs, compile-driver smoke tests (Cancun vs Osaka Yul), and IR proof surfaces (source semantics returns
noneuntil specialized; proof predicates treat it like other branching forms or as unsupported where appropriate). Default Lean elaboration offork_if_at_leaststill reduces to thethenbranch unless consumers override.Reviewed by Cursor Bugbot for commit 67df694. Bugbot is set up for automated code reviews on this repo. Configure here.