Repository navigation
hy-check(addr_loan): run second-pass loop-carried slot-loan checks on top-level for loops and reject &pa[0]["k"] pointer-to-array map borrows (Fixes #4039) - #4040
Open
Burapa-J wants to merge 2 commits into
Conversation
…loop bodies and ptr-array map borrows
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.
Fixes #4039
Cause
check_stmt_addr_of_loan_projections(compiler/crates/hy-check/src/addr_loan.rs:329-331) gated the second passself.walk_for_loop_carried(&mut carry_st, kind, body, true)behindif include_direct_ident, which isfalsefor all top-levelforloops outside closures. NestedStmt::Forinsidewalk_for_loop_carriedalso ran only a single pass whenemit == true.is_map_element_or_value_projectionandplace_is_map_element_or_value_projection(addr_loan.rs:692-742) did not unwrapTypeShape::Pointer(Map | Array)onExpr::Index/PlaceKind::Indexbases (&pa[0]["a"]).Fix
self.walk_for_loop_carried(&mut carry_st, kind, body, true)onStmt::Forincheck_stmt_addr_of_loan_projectionsand seed nestedStmt::Forloops before emitting inwalk_for_loop_carried.expr_borrow_shapeand handleTypeShape::Pointer(Map | Array)inis_map_element_or_value_projectionandplace_is_map_element_or_value_projection.compiler/crates/hy-check/tests/addr_loan_place_rebind_and_loop_carry.rs.Verification
cargo test -p hy-check --lib --test addr_loan_place_rebind_and_loop_carry --test addr_of_loan(201 passed, 0 failed)Settlement Wallet (Base / Polygon USDC):
0x46489A4fe1D0B5568352010257fEC049093f527a