Skip to content

fix: croak on trailing dash-option without CODE ref in import#90

Draft
Koan-Bot wants to merge 2 commits intocpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-import-trailing-option
Draft

fix: croak on trailing dash-option without CODE ref in import#90
Koan-Bot wants to merge 2 commits intocpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-import-trailing-option

Conversation

@Koan-Bot
Copy link
Copy Markdown
Contributor

@Koan-Bot Koan-Bot commented Apr 18, 2026

What

Detect and error on incomplete mock declarations in the import() argument list.

Why

use Overload::FileCheck '-e' => sub { 1 }, '-f' silently discarded the trailing -f — the user thinks they're mocking two operators but only one is active. This is a silent data loss bug.

How

Added a post-loop check: if $_next_check is still set after processing all import args, croak with a clear message naming the orphaned option. Also optimized the -B handler in _check_from_stat() to check directory mode bits directly from the cached @stat array instead of dispatching through the full mock system (which triggered a redundant stat callback).

Testing

  • New t/import-trailing-option.t covers both the single-option and trailing-option cases
  • Full test suite passes (1443 subtests)

🤖 Generated with Claude Code


Quality Report

Changes: 2 files changed, 49 insertions(+), 1 deletion(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Koan-Bot and others added 2 commits April 17, 2026 23:56
Previously, `use Overload::FileCheck '-e' => sub { 1 }, '-f'` would
silently discard the trailing `-f` option. Now it produces a clear
error message indicating the missing CODE ref.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The -B handler in _check_from_stat() was calling `-d $f_or_fh` to
detect directories, which dispatched through the full mock system and
triggered a second stat callback. Use _check_mode_type() on the
already-fetched @stat array instead — same result, zero extra calls.

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