Skip to content

fix: preserve logical static-evaluation branches - #639

Open
hamza-paracha wants to merge 1 commit into
vercel:mainfrom
hamza-paracha:fix/logical-conditional-branches
Open

hamza-paracha wants to merge 1 commit into
vercel:mainfrom
hamza-paracha:fix/logical-conditional-branches

Conversation

@hamza-paracha

Copy link
Copy Markdown

For && / || where the right side is conditional, static evaluation built the else branch from the left operand's wrapper object (l) instead of its value (v), so that branch was an object and not a string, and its dependency was dropped:

const file = false || (process.env.USE_A ? './a' : './b');
require(file); // only a.js was traced, b.js was missing

The fix in src/utils/static-eval.ts uses v for both branches, as the ifTrue branch already did.

Tests: test/static-eval-logical.test.js (falsy, empty-string, truthy and short-circuit cases) and a test/unit/logical-conditional tracing fixture. Both fail without the fix. The full suite passes, as do pnpm build and pnpm prettier-check.

This fix was written with help from Devin (AI coding agent), reviewed and submitted by me. The commit carries a Co-Authored-By trailer.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@hamza-paracha
hamza-paracha requested review from a team, icyJoseph, ijjk and styfle as code owners November 21, 2026 19:26
Copilot AI balanced review requested due to automatic review settings November 21, 2026 19:26

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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