Skip to content

fix: validate iterator return value in array/complex64 - #17103

Open
SatyamPandey-07 wants to merge 1 commit into
stdlib-js:developfrom
SatyamPandey-07:bugfix/complex64-iterator-validation
Open

SatyamPandey-07 wants to merge 1 commit into
stdlib-js:developfrom
SatyamPandey-07:bugfix/complex64-iterator-validation

Conversation

@SatyamPandey-07

Copy link
Copy Markdown

Resolves #17102.

Description

What is the purpose of this pull request?

This pull request:

  • Fixes an unhandled TypeError (Cannot read properties of null/undefined (reading 'next')) in Complex64Array and Complex64Array.from (@stdlib/array/complex64) by guarding buf.next with !isObject( buf ) after invoking Symbol.iterator.
  • Fixes the Complex64Array constructor error message so it reports the original input argument (arguments[ 0 ]) instead of the overwritten Symbol.iterator return value (buf), resolving the existing FIXME.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Reference Packages

Did the content of this pull request follow one or more existing packages? Answering is optional.

This pull request followed these packages:

  • array/bool (lib/node_modules/@stdlib/array/bool/lib/main.js)

What carried over from the reference(s)?

  • Preserving and formatting the original input argument in the TypeError message when [Symbol.iterator]() does not return a valid iterator.

What differed, or what did you have to work out yourself?

  • Added an explicit !isObject( buf ) check prior to !isFunction( buf.next ) so non-object return values (e.g., null or undefined) from [Symbol.iterator]() produce the formatted TypeError rather than throwing a property-access error.

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.

Verified locally with Node.js assert checks against @stdlib/array/complex64 (new Complex64Array and Complex64Array.from with null and primitive [Symbol.iterator]() return values, as well as valid iterables). Note that the full tape test suite was not run locally because node_modules / tape is not installed in the local checkout.

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.".

An AI coding assistant (Antigravity) was used to locate the issue, draft the fix in lib/node_modules/@stdlib/array/complex64/lib/main.js, and run local Node.js verification checks.


@stdlib-js/reviewers

@SatyamPandey-07
SatyamPandey-07 requested a review from a team December 3, 2026 06:41
@stdlib-bot

Copy link
Copy Markdown
Contributor

👋 Hi there! 👋

And thank you for opening your first pull request! We will review it shortly. 🏃 💨

Getting Started

Next Steps

  1. A project maintainer will approve GitHub Actions workflows for your PR.
  2. All CI checks must pass before your submission can be fully reviewed.
  3. You'll need to address any failures in linting or unit tests.

Running Tests Locally

You can use make to run any of the CI commands locally from the root directory of the stdlib repository:

# Run tests for all packages in the math namespace:
make test TESTS_FILTER=".*/@stdlib/math/.*"

# Run benchmarks for a specific package:
make benchmark BENCHMARKS_FILTER=".*/@stdlib/math/base/special/sin/.*"

If you haven't heard back from us within two weeks, please ping us by tagging the "reviewers" team in a comment on this PR.

If you have any further questions while waiting for a response, please join our Zulip community to chat with project maintainers and other community members.

We appreciate your contribution!

Documentation Links

@SatyamPandey-07

Copy link
Copy Markdown
Author

@Planeshifter Hi, just bumping this PR in case it slipped through your notifications. Let me know if you need any changes or further testing!

@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. First-time Contributor A pull request from a contributor who has never previously committed to the project repository. labels Dec 3, 2026

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

First-time Contributor A pull request from a contributor who has never previously committed to the project repository. Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Unhandled TypeError and incorrect error value when Complex64Array receives an invalid iterable

2 participants