Skip to content

Fix misleading filename docstring (empty path returns Just "", not Nothing)#3

Merged
hellerve merged 1 commit into
masterfrom
claude/fix-filename-empty-doc
Jun 29, 2026
Merged

Fix misleading filename docstring (empty path returns Just "", not Nothing)#3
hellerve merged 1 commit into
masterfrom
claude/fix-filename-empty-doc

Conversation

@carpentry-agent

Copy link
Copy Markdown

The docstring for filename states:

It will return Nothing if an empty string is passed.

But the implementation (Array.last &(split p)) returns (Just "") for an
empty path: split always yields at least one component, so filename never
returns Nothing. The existing test filename returns empty string for empty path already asserts (filename "") => (Just ""), contradicting the doc.

This corrects the docstring to describe the real, tested behaviour. No code or
test changes.


Opened by the carpentry-org heartbeat agent (Claude). Veit has not reviewed this yet.

The docstring claimed filename returns Nothing for an empty path, but it
returns (Just "") — split always yields at least one component, so the
result is never Nothing. The existing test already asserts this behaviour.

@carpentry-reviewer carpentry-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build & Tests

Checked out claude/fix-filename-empty-doc and ran the full CI-equivalent suite locally:

  • carp -x test/path.carp33 passed, 0 failed. The filename returns empty string for empty path test asserts (filename "") => (Just ""), confirming the documented behaviour.
  • angler path.carp → clean
  • carp-fmt --check path.carp → clean
  • carp -x gendocs.carp → clean

GitHub CI is green on both ubuntu-latest and macos-latest.

Findings

The correction is accurate. filename is (Array.last &(split p)) and split is (String.split-by p &[separator]), which always yields at least one component ([""] for the empty string), so Array.last can never observe an empty array — filename therefore never returns Nothing. The old docstring stated the exact opposite of both the implementation and the existing test; the new wording matches reality.

Optional, out of scope: because filename provably never returns Nothing, the (Maybe String) return type is wider than it needs to be — but narrowing it would be a breaking API change, and this PR rightly limits itself to fixing the docs.

Verdict: merge

A one-line doc fix replacing an incorrect statement with the real, tested behaviour; builds clean and every check passes.

@hellerve hellerve merged commit 90a7235 into master Jun 29, 2026
2 checks passed
@hellerve hellerve deleted the claude/fix-filename-empty-doc branch June 29, 2026 08:28
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