Repository navigation
fix(hy-check): close place-call, paren-callee, and A3/const bypasses (fixes #500) - #511
Closed
gelismarvel wants to merge 1 commit into
Closed
gelismarvel wants to merge 1 commit into
gelismarvel wants to merge 1 commit into
Conversation
Contributor
Author
|
Closing this PR. On review, its changes substantially duplicate the earlier PR #501 by @o2splatform-cmyk, so it should not have been submitted as separate work. Withdrawing it (and any bounty claim attached to it) in favor of the original. Apologies for the noise. |
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
Fixes #500
Closes five soundness gaps in
hy-checkwhere calls and closures insideStmt::Assigntarget places, parenthesized callees, A3 closure/method/inline-FnLitcallees, and shadowed builtins (delete,copy,len,cap,print,println,make,new,append,close) bypassedHYB-E3003,HYB-E3006,HYB-E3102, andHYB-E2005:walk::own_calls,walk::own_fnlits, andprocess_assigntarget-place traversal (walk.rs,loans.rs,closures.rs,builtins.rs):walk::own_callsto recurse intoStmt::Assigntarget places (PlaceKind::Index,PlaceKind::Field,PlaceKind::AddrOf) viaexpr_calls_in_placeso calls nested inside LHS index expressions (e.g.arr[copy(dst, src)] = 1,arr[delete_helper(m)] = 1) are visited byprocess_call,check_builtin_call, A3 interprocedural mutation scans, and T22 const-mutation scans.walk::own_fnlits/walk::expr_fnlitsand invokecheck_closure_capturesonPlaceKind::Indexindex expressions insideprocess_assignso inline closures inside LHS index expressions are checked for capture/sendability/const-write rules.loans.rs,builtins.rs,closures.rs):unwrap_parens(cr.callee)acrossresolve_call,call_mutates_param,collect_mutation_roots,call_mutates_const_param,check_builtin_call, andexpr_contains_spawn_or_sendso(copy)(dst, src),(delete)(m, k), and(mutator)(m)are not misclassified asResolved::Noneor non-builtin calls.FnLitcallee soundness (loans.rs,model.rs):FnState::closure_param_mutates(with scope stackclosure_param_scopesinFnState::scope_push/scope_pop) and check them viacheck_a3_closure_param_conflict.Resolved::Method->check_a3_method_conflict) and inlineFnLit/ computed expression callees (Resolved::None->check_a3_inline_or_expr_call) against live A3 map-slot loans, usingLexicalStructMapto disambiguate receiver struct types while failing closed when a receiver or callee cannot be statically narrowed.builtins.rs,loans.rs):delete,copy,A3_PURE_FNS,A3_PURE_PKGS, andcheck_builtin_callarity/type checks) withself.lookup_binding(st, name).is_none()and lexical shadow tracking so local variables or parameters nameddelete,copy,len,fmt, etc. neither trigger false-positive builtin diagnostics nor grantA3_PURE_FNS/A3_PURE_PKGSexemptions to mutating closures.constdeep-immutability (HYB-E3006) acrossMatch,Select, and non-Identcallees (loans.rs):stmt_mutates_const_paramandcall_mutates_const_paramto traverseStmt::MatchandStmt::Selectarms, method calls, inlineFnLitcalls, and unknown/closure callees (failing closed when aconst-aliased reference is passed).Verification
compiler/crates/hy-check/tests/place_call_and_a3_callee_soundness.rs.cargo test --manifest-path compiler/Cargo.toml -p hy-checkpasses completely (137/137unit tests +14/14place_call_and_a3_callee_soundness+ all integration test suites,0warnings).