Skip to content

fix: add parentheses to NaN macros - #15676

Merged
kgryte merged 1 commit into
stdlib-js:developfrom
anandkaranubc:fix-nan-macro-parentheses
Sep 30, 2026
Merged

kgryte merged 1 commit into
stdlib-js:developfrom
anandkaranubc:fix-nan-macro-parentheses

Conversation

@anandkaranubc

@anandkaranubc anandkaranubc commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Resolves stdlib-js/metr-issue-tracker#1391

Description

What is the purpose of this pull request?

This pull request:

  • Wraps STDLIB_CONSTANT_FLOAT64_NAN and STDLIB_CONSTANT_FLOAT32_NAN in parentheses so they always act as a single value. Without them, 1.0 / STDLIB_CONSTANT_FLOAT64_NAN expands to 1.0 / 0.0/0.0, which is inf instead of NaN.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

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.

I checked all current uses of both macros and none of them are affected, so this does not change any existing output. It just makes the macros safe to use inside larger expressions as #11743 moves more code over to them.

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

@stdlib-js/reviewers

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@anandkaranubc
anandkaranubc requested a review from a team September 30, 2026 03:11
@anandkaranubc anandkaranubc added Bug Something isn't working. C Issue involves or relates to C. METR Pull request associated with the METR project. labels Sep 30, 2026
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 30, 2026
@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Sep 30, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
constants/float32/nan $\\color{green}48/48$
$\\color{green}+100.00\\%$
$\\color{green}1/1$
$\\color{green}+100.00\\%$
$\\color{green}0/0$
$\\color{green}+100.00\\%$
$\\color{green}48/48$
$\\color{green}+100.00\\%$
constants/float64/nan $\\color{green}48/48$
$\\color{green}+100.00\\%$
$\\color{green}1/1$
$\\color{green}+100.00\\%$
$\\color{green}0/0$
$\\color{green}+100.00\\%$
$\\color{green}48/48$
$\\color{green}+100.00\\%$

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

@kgryte kgryte added review: 5 and removed Needs Review A pull request which needs code review. labels Sep 30, 2026

@kgryte kgryte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for fixing, @anandkaranubc!

@kgryte kgryte changed the title fix: add parentheses to NaN macros in constants/float*/nan fix: add parentheses to NaN macros Sep 30, 2026
@kgryte
kgryte merged commit fb5ec21 into stdlib-js:develop Sep 30, 2026
122 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working. C Issue involves or relates to C. Good First PR A pull request resolving a Good First Issue. METR Pull request associated with the METR project. review: 5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add parentheses to NaN macros in constants/float*/nan

3 participants