Skip to content

fix: validate command name type and fix Timer.pm POD errors - #296

Draft
toddr-bot wants to merge 1 commit into
cpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-nested-arrayref-error
Draft

fix: validate command name type and fix Timer.pm POD errors#296
toddr-bot wants to merge 1 commit into
cpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-nested-arrayref-error

Conversation

@toddr-bot

@toddr-bot toddr-bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

What

Catch references passed as command names early in the harness parser, and fix Timer.pm documentation bugs.

Why

When users accidentally write run [[cmd]] instead of run [cmd], the inner arrayref is stringified to ARRAY(0x...) and produces the confusing error Command 'ARRAY(0x...)' not found in .... A validation check at parse time gives a clear diagnostic:
Command name must be a string, not a ARRAY reference.

Timer.pm's SYNOPSIS had two bugs: $t->time(5) is not a method (the correct call is $t->interval(5)), and both instances were missing semicolons — meaning the next statement would be parsed as an argument.

How

  • Added a ref $_->[0] check after the existing !defined $_->[0] check in harness(), covering ARRAY, HASH, and CODE references.
  • Fixed $t->time(5)$t->interval(5); in Timer.pm SYNOPSIS (both timeout and timer examples).
  • Removed stale TODO about time parsing (already implemented in _parse_time).
  • Clarified result() POD: signal-killed children also yield undef, with pointer to full_result().

Testing

  • Added 3 tests to t/bogus.t for nested ARRAY, HASH ref, and CODE ref as command name.
  • Full test suite passes on Linux.

Quality Report

Changes: 3 files changed, 34 insertions(+), 9 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan

Detect references (ARRAY, HASH, CODE) passed as command names inside
the command arrayref early in the harness parser, before _search_path
stringifies them into 'ARRAY(0x...)' producing a confusing "not found"
error.  Commonly triggered by accidentally nesting arrays: run [[cmd]]
instead of run [cmd].

Fix Timer.pm SYNOPSIS examples: $t->time(5) is not a method — the
correct call is $t->interval(5), and both instances were missing
semicolons.  Remove stale TODO about time parsing (already implemented
in _parse_time).

Clarify result() POD: document that signal-killed children also yield
undef (since $? >> 8 is 0 for signal deaths), and point to full_result()
for detecting signals.
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