Skip to content

fix: correct IO.pm error messages and remove Timer.pm dead code - #295

Draft
toddr-bot wants to merge 1 commit into
cpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-io-error-msg-and-timer-dead-code
Draft

fix: correct IO.pm error messages and remove Timer.pm dead code#295
toddr-bot wants to merge 1 commit into
cpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-io-error-msg-and-timer-dead-code

Conversation

@toddr-bot

Copy link
Copy Markdown
Contributor

What

Fix misleading error messages in IO.pm and remove unreachable dead code in Timer.pm.

Why

IO.pm: _new_internal() error messages referenced $_ (the caller's topic variable) instead of the $type parameter. When called via IO->new(), $_ was whatever the calling scope had, producing messages like '' missing a source instead of '<' missing a source.

Timer.pm: check() line 365 (return 0 if $self->is_expired) was unreachable — line 364 already returns undef for all non-running timers, which includes expired ones (state=undef). The "expires during this check" case is correctly handled later at lines 376-377 via expire() + return 0.

How

  • IO.pm: Replace $_ with $type in both error messages (lines 150, 173)
  • Timer.pm: Remove the dead guard line
  • Added 4 tests in t/io.t verifying error messages reference the operator, not stale $_

Testing

prove -Ilib t/io.t t/timer.t — all pass. Full suite: 863/863 pass (pty.t skipped due to IO::Pty version).

IO.pm _new_internal() error messages referenced $_ (the caller's topic
variable) instead of $type.  When called via IO->new(), $_ was whatever
the calling scope happened to have, producing misleading error messages
like "'' missing a source".  Use $type so the operator is always shown.

Timer.pm check() had an unreachable guard: line returned 0 if
is_expired, but the preceding line already returned undef for all
non-running timers (which includes expired ones).  The actual
"expires during this check" case is handled later by expire()+return 0.

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