Skip to content

fix: wrap RangeError messages with format#12912

Merged
kgryte merged 2 commits into
developfrom
claude/practical-goodall-gi7x44
Jun 16, 2026
Merged

fix: wrap RangeError messages with format#12912
kgryte merged 2 commits into
developfrom
claude/practical-goodall-gi7x44

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

This pull request:

  • wraps two RangeError throws in @stdlib/ndarray/at with format(...). The current code passes printf-style positional arguments directly to the RangeError constructor, which silently discards them, so the thrown message contains literal %s and %u placeholders instead of the array shape and the index count.

@stdlib/ndarray/at

lib/main.js lines 69 and 71 throw RangeError for "Insufficient arguments" and "Too many arguments". Both messages contain %s and %u format specifiers and pass sh.join(',') and nargs as trailing arguments to new RangeError(...), but the Error constructor only consumes the first argument as the message. The trailing arguments are dropped, and the user sees the literal placeholders.

The fix wraps each message in format(...), matching the canonical pattern. The format module is already imported at line 27 and used for the TypeError throws on lines 63 and 77 in the same function, so no new dependency is introduced. Format-wrapped error construction is the convention in 114 of 115 throwing siblings in the @stdlib/ndarray/* namespace (~99% conformance).

Related Issues

Does this pull request have any related issues?

No.

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request?

No test assertions check the error message text — test/test.js only verifies the error constructor type — so the fix does not affect test expectations. No downstream consumers in @stdlib/ndarray string-match the affected messages.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

This PR was authored by Claude Code as part of an automated cross-package drift-detection routine over the @stdlib/ndarray namespace. The drift was identified by structural and pattern-based analysis of error-construction conventions across the 136 sibling packages and confirmed by two independent automated validation passes (semantic review and cross-reference review of tests, examples, REPL docs, type declarations, and downstream consumers). A human will audit and promote the PR out of draft.


@stdlib-js/reviewers


Generated by Claude Code

In `@stdlib/ndarray/at`, the `RangeError` throws for insufficient and
excess index arguments pass printf-style positional arguments directly
to the `RangeError` constructor instead of through `format()`. The
constructor discards the trailing arguments, so the thrown message
contains literal `%s` and `%u` placeholders rather than the array
shape and index count.

Wrap both throws with `format(...)`, matching the canonical error-
construction pattern used by the sibling `TypeError` throws in the
same file (lines 63 and 77) and by the wider `ndarray/*` namespace
(format-wrapped error construction in 114 of 115 throwing siblings).
The `format` module is already required at the top of the file, so
no new dependency is introduced. No test assertions check the error
message text, so the fix does not affect test expectations.
@stdlib-bot

stdlib-bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
ndarray/at $\\color{green}140/140$
$\\color{green}+100.00\\%$
$\\color{green}15/15$
$\\color{green}+100.00\\%$
$\\color{green}1/1$
$\\color{green}+100.00\\%$
$\\color{green}140/140$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

Signed-off-by: Athan <kgryte@gmail.com>
@kgryte kgryte marked this pull request as ready for review June 16, 2026 00:15
@kgryte kgryte requested a review from a team June 16, 2026 00:15
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jun 16, 2026
@kgryte kgryte removed the Needs Review A pull request which needs code review. label Jun 16, 2026
@kgryte kgryte changed the title fix: wrap RangeError messages with format in @stdlib/ndarray/at fix: wrap RangeError messages with format Jun 16, 2026
@kgryte kgryte merged commit aedcf13 into develop Jun 16, 2026
32 checks passed
@kgryte kgryte deleted the claude/practical-goodall-gi7x44 branch June 16, 2026 01:05
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.

4 participants