Skip to content

Apply automatic clippy fixes in HIR#5423

Merged
proggeramlug merged 6 commits into
mainfrom
feat/clippy-hir-auto-fixes
Jun 19, 2026
Merged

Apply automatic clippy fixes in HIR#5423
proggeramlug merged 6 commits into
mainfrom
feat/clippy-hir-auto-fixes

Conversation

@TheHypnoo

@TheHypnoo TheHypnoo commented Jun 18, 2026

Copy link
Copy Markdown
Member

Summary

  • Applies mechanical cargo clippy --fix suggestions in crates/perry-hir.
  • Keeps the change scoped to HIR lowering, transform, destructuring, and monomorph helper code.

Validation

  • cargo fmt --all -- --check
  • cargo clippy -p perry-hir -- -A clippy::not_unsafe_ptr_arg_deref

Remaining clippy output is pre-existing warning debt not covered by automatic fixes in this branch.

Summary by CodeRabbit

  • Bug Fixes
    • Improved per-package capability enforcement by evaluating wildcard/allowed and required-capability violations using direct membership checks for more consistent behavior.
  • Refactor
    • Reworked many analysis and lowering dispatch paths to use pattern-guard style instead of nested conditionals.
    • Simplified boolean/optional handling and tightened argument gating in built-in lowering cases while preserving behavior.
  • Chores
    • Trimmed and narrowed internal imports and crate-visible re-exports.
  • Tests
    • Adjusted crate-private name mangling exports so mangle_type is available only during tests.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 538f66f6-f9fb-4c50-82f8-71fee8e64323

📥 Commits

Reviewing files that changed from the base of the PR and between df04fe5 and 877953d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • crates/perry-hir/src/destructuring/helpers.rs
  • crates/perry-hir/src/destructuring/mod.rs
  • crates/perry-hir/src/destructuring/var_decl.rs
  • crates/perry-hir/src/lower/expr_call/array_only_methods.rs
  • crates/perry-hir/src/lower/expr_call/globals.rs
  • crates/perry-hir/src/lower/expr_call/local_array_methods.rs
  • crates/perry-hir/src/lower/expr_call/native_module.rs
  • crates/perry-hir/src/lower/expr_call/regex_string.rs
  • crates/perry-hir/src/lower/expr_member.rs
  • crates/perry-hir/src/lower/expr_new.rs
  • crates/perry-hir/src/lower/lower_expr.rs
  • crates/perry-hir/src/lower/module_decl.rs
  • crates/perry-hir/src/lower_decl/block.rs
  • crates/perry-hir/src/lower_decl/body_stmt.rs
  • crates/perry-hir/src/lower_decl/class_decl.rs
  • crates/perry-hir/src/lower_decl/class_members.rs
  • crates/perry-hir/src/lower_decl/fn_decl.rs
  • crates/perry-hir/src/lower_decl/private_members.rs
✅ Files skipped from review due to trivial changes (5)
  • crates/perry-hir/src/lower_decl/private_members.rs
  • crates/perry-hir/src/lower_decl/fn_decl.rs
  • crates/perry-hir/src/destructuring/mod.rs
  • crates/perry-hir/src/lower/lower_expr.rs
  • crates/perry-hir/src/lower_decl/body_stmt.rs
🚧 Files skipped from review as they are similar to previous changes (12)
  • crates/perry-hir/src/destructuring/helpers.rs
  • crates/perry-hir/src/lower/expr_call/regex_string.rs
  • crates/perry-hir/src/lower/expr_member.rs
  • crates/perry-hir/src/lower/expr_call/array_only_methods.rs
  • crates/perry-hir/src/lower_decl/block.rs
  • crates/perry-hir/src/lower_decl/class_decl.rs
  • crates/perry-hir/src/lower/expr_new.rs
  • crates/perry-hir/src/lower_decl/class_members.rs
  • crates/perry-hir/src/lower/expr_call/globals.rs
  • crates/perry-hir/src/lower/module_decl.rs
  • crates/perry-hir/src/lower/expr_call/native_module.rs
  • crates/perry-hir/src/lower/expr_call/local_array_methods.rs

📝 Walkthrough

Walkthrough

A broad cleanup of crates/perry-hir: unused imports are removed and wildcard imports narrowed across ~30 files, pub(crate) re-export surfaces are trimmed in multiple mod.rs files, and control flow inside match dispatch blocks is converted from nested-if-inside-arm to Rust match-guard syntax throughout the lowering pipeline. No observable behavior changes.

Changes

perry-hir: Import cleanup, re-export narrowing, and match-guard refactoring

Layer / File(s) Summary
Crate-internal re-export surface narrowing
crates/perry-hir/src/analysis.rs, crates/perry-hir/src/destructuring/mod.rs, crates/perry-hir/src/lower/mod.rs, crates/perry-hir/src/lower_decl/mod.rs, crates/perry-hir/src/monomorph/mod.rs, crates/perry-hir/src/js_transform/mod.rs
Several hub mod.rs files remove specific names from their pub(crate) use lists: dropped names include uses_*_expr helpers, require_resolvable_native_specifier, lower_fn_expr, PRIV_OP_READ, context::*, ForHeadBinding, iterator_close_guarded_stmt, iterator_next_call, several is_known_* recognizers, collect_refs_in_closure_bodies_stmt, collect_top_level_let_ids_stmt, and mangle_type (test-only).
Import narrowing across ~25 lowering and analysis files
crates/perry-hir/src/lower/expr_call/*, crates/perry-hir/src/lower_decl/*, crates/perry-hir/src/js_transform/*
Unused symbols are removed from import lists throughout: anyhow/bail trimmed to only what is referenced, LocalId and broad wildcards (crate::analysis::*, crate::destructuring::*, super::*) dropped, and std::collections narrowed to the container type(s) actually used. No logic changes.
Match-guard refactoring in globals and module-static dispatch
crates/perry-hir/src/lower/expr_call/globals.rs, crates/perry-hir/src/lower/expr_call/module_static.rs
Nested-if-inside-match-arm patterns are converted to Rust match-guard arms across child_process, path, url, fs, WebAssembly, Math, crypto, and Buffer method dispatch tables. The same HIR constructors and argument handling are preserved; only control-flow structure changes.
Guard-based refactor for array-method lowering
crates/perry-hir/src/lower/expr_call/array_only_methods.rs, crates/perry-hir/src/lower/expr_call/imported_array_methods.rs, crates/perry-hir/src/lower/expr_call/inline_array_methods.rs, crates/perry-hir/src/lower/expr_call/local_array_methods.rs
Array method dispatch tables (map, filter, forEach, reduce, sort, etc.) switch to guarded match arms. A receiver_is_class_instance helper is extracted for sort fast-path gating. The push spread loop zips directly with args instead of args.into_iter(), and TextDecoder/push fallback conditions are consolidated without behavioral change.
Guard refactors in module-class-static, native-module, and dispatch helpers
crates/perry-hir/src/lower/expr_call/module_class_static.rs, crates/perry-hir/src/lower/expr_call/native_module.rs, crates/perry-hir/src/lower/expr_call/nested_namespace.rs
process.stdin/process.stdout, Buffer.compare, Object.groupBy, and path sub-namespace dispatch arms switch to match guards. Argument extraction and constructed expression variants remain unchanged.
Idiom and guard refactors in analysis, lowering, and declaration code
crates/perry-hir/src/capability.rs, crates/perry-hir/src/destructuring/helpers.rs, crates/perry-hir/src/destructuring/var_decl.rs, crates/perry-hir/src/egress.rs, crates/perry-hir/src/lower/eval_super_scan.rs, crates/perry-hir/src/lower/expr_assign.rs, crates/perry-hir/src/lower/expr_member.rs, crates/perry-hir/src/lower/expr_new.rs, crates/perry-hir/src/lower/lower_expr.rs, crates/perry-hir/src/lower/module_decl.rs, crates/perry-hir/src/lower/stmt.rs, crates/perry-hir/src/lower_decl/block.rs, crates/perry-hir/src/lower_decl/class_decl.rs, crates/perry-hir/src/lower_decl/class_validation.rs
Capability uses Vec::contains instead of iter().any(). Destructuring applies Option::is_some_and() and match guards for type narrowing. Egress checks document nested-if preservation with NOTE comments. Expr assignment and member prototype lookups chain with .map(). Expr new removes .as_deref() from method matching. Module declaration and statement lowering flatten namespace/pattern conditionals into guard patterns. Eval super scan uses guard patterns for transparent references. Expr lowering uses is_multiple_of() for periodic checks. Block and class-validation apply guard patterns to closure-capture and constructor counting. Class declaration iterator idiom simplified from .into_iter().

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • PerryTS/perry#5050: Modifies uses_this_expr logic that the main PR removes from uses_this re-exports in analysis.rs.
  • PerryTS/perry#5167: Updates the same lower_namespace_as_class first-pass pre-registration in lower/module_decl.rs that this PR refactors with match guards.

Poem

🐇 Hop, hop through the match arms I go,
Nested ifs were cluttering the flow!
Import lists trimmed, re-exports refined,
Guard patterns keep the logic aligned.
A cleaner warren — tidy, bright, and true! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description provides a summary of changes, validation steps performed, and acknowledges remaining pre-existing warnings. However, it does not follow the repository's description template structure with required sections like 'Changes', 'Related issue', and 'Test plan' checkboxes. Consider following the repository's PR description template more closely, including the 'Changes' bullet list section and 'Test plan' checklist items for consistency with repository conventions.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: applying automatic clippy fixes to the HIR crate. It is concise, specific, and directly related to the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/clippy-hir-auto-fixes

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/perry-hir/src/lower/module_decl.rs (1)

1957-1961: ⚠️ Potential issue | 🔴 Critical

Add declare namespace guard to nested_namespace_name or guard the unguarded match arm at line 2304.

The function nested_namespace_name (line 1956) documents that it should return None for bodiless declare modules, but it only checks the body—not the declare flag itself. Meanwhile, at line 2304, an unguarded ast::Decl::TsModule(ts_module) => arm calls lower_nested_namespace directly, bypassing the if !ts_module.declare guards present in all other nested namespace callsites (lines 2102, 2111, 2172). If a declare namespace has a body, the function could incorrectly process it as a runtime namespace.

Add an explicit check:

Suggested fix
 fn nested_namespace_name(ts_module: &ast::TsModuleDecl) -> Option<String> {
+    if ts_module.declare {
+        return None;
+    }
     ts_module.body.as_ref()?;
     match &ts_module.id {
         ast::TsModuleName::Ident(ident) => Some(ident.sym.to_string()),
         ast::TsModuleName::Str(_) => None,
     }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/perry-hir/src/lower/module_decl.rs` around lines 1957 - 1961, The
function `nested_namespace_name` checks only whether a namespace has a body but
does not verify the `declare` flag, yet the documentation states it should
return None for bodiless declare modules. Additionally, the unguarded match arm
for `ast::Decl::TsModule` at line 2304 calls `lower_nested_namespace` without
checking the `declare` flag, unlike all other callsites (lines 2102, 2111, 2172)
which have `if !ts_module.declare` guards. Add an explicit check for the
`declare` flag in the `nested_namespace_name` function or add an `if
!ts_module.declare` guard at the unguarded match arm at line 2304 to prevent
declare namespaces from being incorrectly processed as runtime namespaces.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@crates/perry-hir/src/lower/module_decl.rs`:
- Around line 1957-1961: The function `nested_namespace_name` checks only
whether a namespace has a body but does not verify the `declare` flag, yet the
documentation states it should return None for bodiless declare modules.
Additionally, the unguarded match arm for `ast::Decl::TsModule` at line 2304
calls `lower_nested_namespace` without checking the `declare` flag, unlike all
other callsites (lines 2102, 2111, 2172) which have `if !ts_module.declare`
guards. Add an explicit check for the `declare` flag in the
`nested_namespace_name` function or add an `if !ts_module.declare` guard at the
unguarded match arm at line 2304 to prevent declare namespaces from being
incorrectly processed as runtime namespaces.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0c5cbe22-1029-4176-8a80-3c85b1549443

📥 Commits

Reviewing files that changed from the base of the PR and between c84bba3 and ff9fb81.

📒 Files selected for processing (47)
  • crates/perry-hir/src/analysis.rs
  • crates/perry-hir/src/capability.rs
  • crates/perry-hir/src/destructuring/helpers.rs
  • crates/perry-hir/src/destructuring/mod.rs
  • crates/perry-hir/src/destructuring/var_decl.rs
  • crates/perry-hir/src/egress.rs
  • crates/perry-hir/src/js_transform/cross_module_natives.rs
  • crates/perry-hir/src/js_transform/imports.rs
  • crates/perry-hir/src/js_transform/local_natives.rs
  • crates/perry-hir/src/js_transform/mod.rs
  • crates/perry-hir/src/lower/eval_super_scan.rs
  • crates/perry-hir/src/lower/expr_assign.rs
  • crates/perry-hir/src/lower/expr_call/array_only_methods.rs
  • crates/perry-hir/src/lower/expr_call/globals.rs
  • crates/perry-hir/src/lower/expr_call/imported_array_methods.rs
  • crates/perry-hir/src/lower/expr_call/inline_array_methods.rs
  • crates/perry-hir/src/lower/expr_call/local_array_methods.rs
  • crates/perry-hir/src/lower/expr_call/mod.rs
  • crates/perry-hir/src/lower/expr_call/module_class_static.rs
  • crates/perry-hir/src/lower/expr_call/module_static.rs
  • crates/perry-hir/src/lower/expr_call/native_module.rs
  • crates/perry-hir/src/lower/expr_call/nested_namespace.rs
  • crates/perry-hir/src/lower/expr_call/regex_string.rs
  • crates/perry-hir/src/lower/expr_call/static_and_instance.rs
  • crates/perry-hir/src/lower/expr_call/textencoder.rs
  • crates/perry-hir/src/lower/expr_call/url_date_instance.rs
  • crates/perry-hir/src/lower/expr_call/wasm_exports.rs
  • crates/perry-hir/src/lower/expr_member.rs
  • crates/perry-hir/src/lower/expr_new.rs
  • crates/perry-hir/src/lower/lower_expr.rs
  • crates/perry-hir/src/lower/mod.rs
  • crates/perry-hir/src/lower/module_decl.rs
  • crates/perry-hir/src/lower/stmt.rs
  • crates/perry-hir/src/lower_decl/block.rs
  • crates/perry-hir/src/lower_decl/body_stmt.rs
  • crates/perry-hir/src/lower_decl/class_captures.rs
  • crates/perry-hir/src/lower_decl/class_decl.rs
  • crates/perry-hir/src/lower_decl/class_members.rs
  • crates/perry-hir/src/lower_decl/class_validation.rs
  • crates/perry-hir/src/lower_decl/enum_decl.rs
  • crates/perry-hir/src/lower_decl/fn_decl.rs
  • crates/perry-hir/src/lower_decl/helpers.rs
  • crates/perry-hir/src/lower_decl/interface_decl.rs
  • crates/perry-hir/src/lower_decl/mod.rs
  • crates/perry-hir/src/lower_decl/private_members.rs
  • crates/perry-hir/src/lower_decl/type_alias.rs
  • crates/perry-hir/src/monomorph/mod.rs
💤 Files with no reviewable changes (2)
  • crates/perry-hir/src/lower_decl/mod.rs
  • crates/perry-hir/src/js_transform/mod.rs

TheHypnoo and others added 5 commits June 19, 2026 00:27
- Re-add mangle_type re-export (gated #[cfg(test)]) consumed by monomorph tests
- Revert clippy collapsible_if/match-guard rewrite in egress check_url/check_host
  that changed semantics: an allowlisted literal now incorrectly fell through to
  the dynamic-host violation arm

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…fixes

# Conflicts:
#	crates/perry-hir/src/destructuring/mod.rs
#	crates/perry-hir/src/lower/expr_call/array_only_methods.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/perry-hir/src/destructuring/var_decl.rs`:
- Around line 1907-1937: The PutValueSet pattern match transformation is
extracting and storing the value in a temporary variable before target/key are
evaluated, which reverses the normal assignment evaluation order. Reorder the
temporary variable assignments and result statements so that target and key
expressions are evaluated first, then the value is extracted into the temporary,
ensuring the original left-to-right evaluation semantics are preserved. This
means creating temporaries for target/key evaluation before extracting the value
into the __nx_member_init temporary.
- Around line 1915-1919: The issue is that the compiler-generated temporary
local variable uses a hardcoded constant name "__nx_member_init" which can
collide with user-defined bindings in the same scope. Instead of using the fixed
string for the name field in the Stmt::Let, generate a unique synthetic name for
this temporary variable. The tmp_id returned from ctx.define_local should be
used to derive a unique name (such as prefixing with an underscore and including
the ID) to avoid any potential collisions while keeping the variable
distinguishable in debug output.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 538f66f6-f9fb-4c50-82f8-71fee8e64323

📥 Commits

Reviewing files that changed from the base of the PR and between df04fe5 and 877953d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • crates/perry-hir/src/destructuring/helpers.rs
  • crates/perry-hir/src/destructuring/mod.rs
  • crates/perry-hir/src/destructuring/var_decl.rs
  • crates/perry-hir/src/lower/expr_call/array_only_methods.rs
  • crates/perry-hir/src/lower/expr_call/globals.rs
  • crates/perry-hir/src/lower/expr_call/local_array_methods.rs
  • crates/perry-hir/src/lower/expr_call/native_module.rs
  • crates/perry-hir/src/lower/expr_call/regex_string.rs
  • crates/perry-hir/src/lower/expr_member.rs
  • crates/perry-hir/src/lower/expr_new.rs
  • crates/perry-hir/src/lower/lower_expr.rs
  • crates/perry-hir/src/lower/module_decl.rs
  • crates/perry-hir/src/lower_decl/block.rs
  • crates/perry-hir/src/lower_decl/body_stmt.rs
  • crates/perry-hir/src/lower_decl/class_decl.rs
  • crates/perry-hir/src/lower_decl/class_members.rs
  • crates/perry-hir/src/lower_decl/fn_decl.rs
  • crates/perry-hir/src/lower_decl/private_members.rs
✅ Files skipped from review due to trivial changes (5)
  • crates/perry-hir/src/lower_decl/private_members.rs
  • crates/perry-hir/src/lower_decl/fn_decl.rs
  • crates/perry-hir/src/destructuring/mod.rs
  • crates/perry-hir/src/lower/lower_expr.rs
  • crates/perry-hir/src/lower_decl/body_stmt.rs
🚧 Files skipped from review as they are similar to previous changes (12)
  • crates/perry-hir/src/destructuring/helpers.rs
  • crates/perry-hir/src/lower/expr_call/regex_string.rs
  • crates/perry-hir/src/lower/expr_member.rs
  • crates/perry-hir/src/lower/expr_call/array_only_methods.rs
  • crates/perry-hir/src/lower_decl/block.rs
  • crates/perry-hir/src/lower_decl/class_decl.rs
  • crates/perry-hir/src/lower/expr_new.rs
  • crates/perry-hir/src/lower_decl/class_members.rs
  • crates/perry-hir/src/lower/expr_call/globals.rs
  • crates/perry-hir/src/lower/module_decl.rs
  • crates/perry-hir/src/lower/expr_call/native_module.rs
  • crates/perry-hir/src/lower/expr_call/local_array_methods.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/perry-hir/src/destructuring/var_decl.rs`:
- Around line 1907-1937: The PutValueSet pattern match transformation is
extracting and storing the value in a temporary variable before target/key are
evaluated, which reverses the normal assignment evaluation order. Reorder the
temporary variable assignments and result statements so that target and key
expressions are evaluated first, then the value is extracted into the temporary,
ensuring the original left-to-right evaluation semantics are preserved. This
means creating temporaries for target/key evaluation before extracting the value
into the __nx_member_init temporary.
- Around line 1915-1919: The issue is that the compiler-generated temporary
local variable uses a hardcoded constant name "__nx_member_init" which can
collide with user-defined bindings in the same scope. Instead of using the fixed
string for the name field in the Stmt::Let, generate a unique synthetic name for
this temporary variable. The tmp_id returned from ctx.define_local should be
used to derive a unique name (such as prefixing with an underscore and including
the ID) to avoid any potential collisions while keeping the variable
distinguishable in debug output.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 538f66f6-f9fb-4c50-82f8-71fee8e64323

📥 Commits

Reviewing files that changed from the base of the PR and between df04fe5 and 877953d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • crates/perry-hir/src/destructuring/helpers.rs
  • crates/perry-hir/src/destructuring/mod.rs
  • crates/perry-hir/src/destructuring/var_decl.rs
  • crates/perry-hir/src/lower/expr_call/array_only_methods.rs
  • crates/perry-hir/src/lower/expr_call/globals.rs
  • crates/perry-hir/src/lower/expr_call/local_array_methods.rs
  • crates/perry-hir/src/lower/expr_call/native_module.rs
  • crates/perry-hir/src/lower/expr_call/regex_string.rs
  • crates/perry-hir/src/lower/expr_member.rs
  • crates/perry-hir/src/lower/expr_new.rs
  • crates/perry-hir/src/lower/lower_expr.rs
  • crates/perry-hir/src/lower/module_decl.rs
  • crates/perry-hir/src/lower_decl/block.rs
  • crates/perry-hir/src/lower_decl/body_stmt.rs
  • crates/perry-hir/src/lower_decl/class_decl.rs
  • crates/perry-hir/src/lower_decl/class_members.rs
  • crates/perry-hir/src/lower_decl/fn_decl.rs
  • crates/perry-hir/src/lower_decl/private_members.rs
✅ Files skipped from review due to trivial changes (5)
  • crates/perry-hir/src/lower_decl/private_members.rs
  • crates/perry-hir/src/lower_decl/fn_decl.rs
  • crates/perry-hir/src/destructuring/mod.rs
  • crates/perry-hir/src/lower/lower_expr.rs
  • crates/perry-hir/src/lower_decl/body_stmt.rs
🚧 Files skipped from review as they are similar to previous changes (12)
  • crates/perry-hir/src/destructuring/helpers.rs
  • crates/perry-hir/src/lower/expr_call/regex_string.rs
  • crates/perry-hir/src/lower/expr_member.rs
  • crates/perry-hir/src/lower/expr_call/array_only_methods.rs
  • crates/perry-hir/src/lower_decl/block.rs
  • crates/perry-hir/src/lower_decl/class_decl.rs
  • crates/perry-hir/src/lower/expr_new.rs
  • crates/perry-hir/src/lower_decl/class_members.rs
  • crates/perry-hir/src/lower/expr_call/globals.rs
  • crates/perry-hir/src/lower/module_decl.rs
  • crates/perry-hir/src/lower/expr_call/native_module.rs
  • crates/perry-hir/src/lower/expr_call/local_array_methods.rs
🛑 Comments failed to post (2)
crates/perry-hir/src/destructuring/var_decl.rs (2)

1907-1937: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Preserve assignment evaluation order in the PutValueSet split.

This transformation evaluates RHS value before target/key, which can change runtime behavior for side-effectful LHS/RHS expressions compared to normal assignment semantics.

Suggested direction
-                    result.push(Stmt::Let {
-                        id: tmp_id,
-                        name: "__nx_member_init".to_string(),
-                        ty: Type::Any,
-                        mutable: false,
-                        init: Some(*value),
-                    });
-                    result.push(Stmt::Expr(Expr::PutValueSet {
-                        target,
-                        key,
-                        value: Box::new(Expr::LocalGet(tmp_id)),
-                        receiver,
-                        strict,
-                    }));
+                    // Keep original assignment ordering:
+                    // 1) evaluate target/key reference parts first
+                    // 2) evaluate value
+                    // 3) perform put + bind result
+                    // Use temporaries for target/key if needed, then value.
+                    // (Implementation can reuse an existing helper that linearizes
+                    // assignment side effects into ordered temps.)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/perry-hir/src/destructuring/var_decl.rs` around lines 1907 - 1937, The
PutValueSet pattern match transformation is extracting and storing the value in
a temporary variable before target/key are evaluated, which reverses the normal
assignment evaluation order. Reorder the temporary variable assignments and
result statements so that target and key expressions are evaluated first, then
the value is extracted into the temporary, ensuring the original left-to-right
evaluation semantics are preserved. This means creating temporaries for
target/key evaluation before extracting the value into the __nx_member_init
temporary.

1915-1919: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid fixed synthetic local name for compiler-generated temp.

Using a constant local name ("__nx_member_init") risks collisions with user bindings in the same scope.

Proposed fix
-                    let tmp_id = ctx.define_local("__nx_member_init".to_string(), Type::Any);
+                    let tmp_name = format!("__nx_member_init_{}", ctx.next_synthetic_id());
+                    let tmp_id = ctx.define_local(tmp_name.clone(), Type::Any);
                     result.push(Stmt::Let {
                         id: tmp_id,
-                        name: "__nx_member_init".to_string(),
+                        name: tmp_name,
                         ty: Type::Any,
                         mutable: false,
                         init: Some(*value),
                     });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/perry-hir/src/destructuring/var_decl.rs` around lines 1915 - 1919, The
issue is that the compiler-generated temporary local variable uses a hardcoded
constant name "__nx_member_init" which can collide with user-defined bindings in
the same scope. Instead of using the fixed string for the name field in the
Stmt::Let, generate a unique synthetic name for this temporary variable. The
tmp_id returned from ctx.define_local should be used to derive a unique name
(such as prefixing with an underscore and including the ID) to avoid any
potential collisions while keeping the variable distinguishable in debug output.

@proggeramlug proggeramlug merged commit 258452f into main Jun 19, 2026
15 checks passed
@proggeramlug proggeramlug deleted the feat/clippy-hir-auto-fixes branch June 19, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants