The job `Node.js v16` on workflow `macos_test` has failed
deterministically on develop for weeks, with 6 assertion failures in
`circshift`'s own test suite. Root cause: when `k` is provided as an
ndarray and no `dims` option is given, `main.js` passed `k` straight
through to the base implementation without validating that it is
zero-dimensional, so a `k` with shape `[4]`, `[2,2,2]`, or `[0]` was
silently accepted instead of raising an error. This commit routes
`k` through the already-imported `maybeBroadcastArray` helper
(already used for the `dims`-provided branch) so that a
non-zero-dimensional `k` throws, matching the function's documented
"`k` is assumed to be a zero-dimensional ndarray" semantics.
Ref: https://github.com/stdlib-js/stdlib/actions/runs/33173054715
Description
This pull request:
Related Issues
This pull request has the following related issues: none. Discovered via automated monitoring of scheduled CI failures on develop, not a filed issue.
Questions
No.
Other
Failing run: https://github.com/stdlib-js/stdlib/actions/runs/33173054715 (job Node.js v16, workflow macos_test; the same failure reproduces on every scheduled run of this workflow going back weeks — not a flake).
Symptom: circshift's own test suite reports 6 failing assertions: circshift(x, k) and circshift(x, k, {}) do not throw when k is an ndarray with shape [4], [2,2,2], or [0] against an x of shape [2,2].
Root cause: in lib/main.js, when k is ndarray-like and no dims option is supplied, the function assumed (per an inline comment) that k was already zero-dimensional and passed it straight to base() with no validation — in both the 2-argument call form and the 3-argument form when opts lacks a dims property.
Fix: route k through maybeBroadcastArray( k, [] ) in both unvalidated branches — the same helper already used one branch over for the dims-provided case, just against a fixed target shape of [] (zero dimensions) instead of the non-core shape. For an already-valid zero-dimensional k, maybeBroadcastArray returns the identical object reference, so the happy path is unchanged; for any higher-rank k, it throws.
Validation: local node_modules are not installed in this environment, so make test/make lint-pkg could not be run directly. Three independent adversarial reviews were performed against the diff and the package's own test suite, docs, and TypeScript declarations:
Reviewer notes: non-blocking — the broadcast helper raises a generic Error rather than a more specific TypeError, and the top-of-file JSDoc @throws list doesn't enumerate the broadcast-incompatibility error (a pre-existing gap on the neighboring dims branch, not introduced by this change). Left as-is for consistency with the existing dims-provided branch.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was found, diagnosed, fixed, and validated autonomously by Claude Code as part of a scheduled CI-failure-monitoring routine, including an independent three-reviewer adversarial validation pass. A human should still review before merging.
@stdlib-js/reviewers
Generated by Claude Code