Skip to content

refactor: remove dead depth==0 guard in av_clone#136

Draft
Koan-Bot wants to merge 2 commits into
garu:masterfrom
Koan-Bot:koan.atoomic/remove-dead-av-clone-guard
Draft

refactor: remove dead depth==0 guard in av_clone#136
Koan-Bot wants to merge 2 commits into
garu:masterfrom
Koan-Bot:koan.atoomic/remove-dead-av-clone-guard

Conversation

@Koan-Bot

@Koan-Bot Koan-Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

What

Remove unreachable depth == 0 check in av_clone().

Why

sv_clone() returns SvREFCNT_inc(ref) when depth == 0 (line 515–516), so av_clone is never reached with depth == 0. The guard was residual from before the sv_clone early 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 the target AV that sv_clone already allocated and passed in as a parameter.

How

Replaced the dead if (depth == 0) block with a comment explaining why depth > 0 is guaranteed at this point.

Testing

Full test suite passes (27 test files). No behavioral change — the removed code was unreachable.

🤖 Generated with Claude Code

Koan-Bot and others added 2 commits May 3, 2026 04:20
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>
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.

1 participant