Fix type ambiguity in anneal spec generation for shadowed type names#3345
Open
nnunley wants to merge 1 commit intogoogle:mainfrom
Open
Fix type ambiguity in anneal spec generation for shadowed type names#3345nnunley wants to merge 1 commit intogoogle:mainfrom
nnunley wants to merge 1 commit intogoogle:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3345 +/- ##
=======================================
Coverage 91.88% 91.88%
=======================================
Files 20 20
Lines 6076 6076
=======================================
Hits 5583 5583
Misses 493 493 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bbe0557 to
2f09ed1
Compare
When a Rust function uses a type via `use` import (e.g., `use std::sync::atomic::Ordering`), the spec generator only sees the short name "Ordering" from the syn AST. This conflicts with Lean's native `Ordering` (core.cmp.Ordering) brought in by `open Aeneas.Std`, causing type mismatches in the generated Pre/Post structs. After Aeneas generates Funs.lean (which contains fully-qualified type names in def signatures), parse those signatures and use the Aeneas types as overrides in spec generation. Falls back to the existing map_type behavior when no Aeneas type info is available.
2f09ed1 to
3f9641d
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.
Summary
When a Rust function uses a type via
useimport (e.g.,use std::sync::atomic::Ordering), the spec generator only sees the short nameOrderingfrom thesynAST. This conflicts with Lean's nativeOrdering(core.cmp.Ordering) brought in byopen Aeneas.Std, causing type mismatches in the generatedPre/Poststructs.Fix
After Aeneas generates
Funs.lean(which contains fully-qualified type names indefsignatures), parse those signatures and use the Aeneas types as overrides in spec generation. Falls back to the existingmap_typebehavior when no Aeneas type info is available.Changes
anneal/src/funs_types.rs(new): Parses Leandefsignatures fromFuns.leanto extract(param_name, lean_type)pairs. Handles single-line, multi-line, generic, and implicit-parameter signatures. Skips implicit{}params.anneal/src/generate.rs: Addsgenerate_artifact_with_typesandgenerate_function_with_typesthat accept aFunsTypeMap. Original signatures preserved as backward-compatible wrappers. Override logic matches params by name and uses theitem_namespacefor correct Aeneas function name lookup.anneal/src/aeneas.rs: ReadsFuns.leanafter Aeneas runs, parses types, passes to spec generation. Undoes theshow→show1patch before parsing so param names match the Rust source.anneal/src/main.rs: Registers new module.Testing
Funs.leanparser)main(pre-existing toolchain issue whereLD_LIBRARY_PATHdoesn't include the managed toolchain'srust/lib/whenANNEAL_USE_PATH_FOR_TOOLS=1is set)Example
Before (broken —
Orderingresolves to Lean'score.cmp.Ordering):After (correct — uses Aeneas's fully-qualified name):