Skip to content

fix: use format for map argument validation errors in array/bool and array/float16 - #16243

Draft
Planeshifter wants to merge 2 commits into
developfrom
claude/cool-johnson-tvgryd
Draft

Planeshifter wants to merge 2 commits into
developfrom
claude/cool-johnson-tvgryd

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

This pull request:

  • wraps the map method's invalid-callback TypeError message in format in @stdlib/array/bool and @stdlib/array/float16, so that error messages interpolate the offending value instead of showing a literal %s.

@stdlib/array/bool

BooleanArray.prototype.map passed the %s template and fcn directly to TypeError, so the message contained a literal %s and the value was dropped. Every other value-interpolating throw in lib/main.js (14/14) uses format, which the file already imports.

@stdlib/array/float16

The Float16Array polyfill's map method had the same defect in lib/polyfill/index.js. All 12 sibling throws in the file use format, which the file already imports.

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? This may include screenshots, references, and/or implementation notes.

Namespace summary. The @stdlib/array namespace has 107 members. Analyzed features: file tree, package.json keys, README sections, error construction, and JSDoc shape (@example, @returns, @module). Features with a clear majority (≥75%) were file tree, package.json keys, README Usage/Examples sections, and JSDoc tags. Features without one were excluded, including error construction across packages (format 61% among packages that throw). Within each affected file, however, format is used in 100% of value-interpolating throws.

Validation. Structural features were extracted by script and semantic features by static parsing of lib/*.js. Each candidate was then reviewed for semantic intent and cross-referenced against tests and docs. The existing test.map.js suites only assert the error type and pass unchanged: array/bool 34/34, array/float16 33/33, and the array/float16 polyfill 34/34. The following were deliberately excluded:

  • deviations in generator-owned files (repl.txt, *.d.ts, ## See Also);
  • packages with open PRs (complex128, slice, float32, float64, uint64, fixed-endian-*);
  • intentional deviations, such as built-in wrapper packages whose lib/main.js re-exports a global and so lacks @example.

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

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was written primarily by Claude Code as part of an automated cross-package API drift detection run.


@stdlib-js/reviewers


Generated by Claude Code

The `map` method passed a `%s` template string and the offending value directly to the `TypeError` constructor, which resulted in an error message containing a literal `%s` placeholder. This commit wraps the message in `format`, in line with every other value-interpolating error message in the package (14 of 14 sibling throws) and the majority of `@stdlib/array` packages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XfJGbrwW1ETRRzyKehDvvX
The `map` method of the `Float16Array` polyfill passed a `%s` template string and the offending value directly to the `TypeError` constructor, which resulted in an error message containing a literal `%s` placeholder. This commit wraps the message in `format`, in line with every other value-interpolating error message in the polyfill (12 of 12 sibling throws) and the majority of `@stdlib/array` packages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XfJGbrwW1ETRRzyKehDvvX
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
array/bool $\\color{red}2730/2747$
$\\color{green}+99.38\\%$
$\\color{red}454/463$
$\\color{green}+98.06\\%$
$\\color{green}55/55$
$\\color{green}+100.00\\%$
$\\color{red}2730/2747$
$\\color{green}+99.38\\%$
array/float16 $\\color{red}2555/2603$
$\\color{green}+98.16\\%$
$\\color{red}452/467$
$\\color{green}+96.79\\%$
$\\color{red}58/59$
$\\color{green}+98.31\\%$
$\\color{red}2555/2603$
$\\color{green}+98.16\\%$

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

This branch has not been deployed

No deployments
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.

3 participants