refactor: remove dead depth==0 guard in av_clone#136
Draft
Koan-Bot wants to merge 2 commits into
Draft
Conversation
sv_clone() returns SvREFCNT_inc(ref) when depth==0 (a no-op copy), so av_clone is never reached with depth 0. The guard was residual from before the sv_clone early return was added. Besides being dead code, the guard had a latent bug: it returned av_clone_iterative(ref,...) which creates a NEW AV, leaking the `target` AV that sv_clone already allocated and passed in. Replace with a comment explaining why depth > 0 is guaranteed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
install-with-cpm@v1 regressed on Perl 5.8-5.22 after a recent cpm update requiring Perl 5.24+. Bump to @v2 for action-based jobs and use direct `cpm install` in the Docker-based Linux matrix (where cpm is pre-installed). Matches the approach approved by @atoomic in PR garu#120. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
What
Remove unreachable
depth == 0check inav_clone().Why
sv_clone()returnsSvREFCNT_inc(ref)whendepth == 0(line 515–516), soav_cloneis never reached withdepth == 0. The guard was residual from before thesv_cloneearly return was introduced.Beyond being dead code, the guard had a latent memory leak: it returned the result of
av_clone_iterative()(a fresh AV), abandoning thetargetAV thatsv_clonealready allocated and passed in as a parameter.How
Replaced the dead
if (depth == 0)block with a comment explaining whydepth > 0is guaranteed at this point.Testing
Full test suite passes (27 test files). No behavioral change — the removed code was unreachable.
🤖 Generated with Claude Code