Skip to content

build: ensure correct operator precedence when using a dynamic require expression - #13537

Merged
kgryte merged 2 commits into
stdlib-js:developfrom
impawstarlight:fix/repl-doctest-new-require
Jul 18, 2026
Merged

kgryte merged 2 commits into
stdlib-js:developfrom
impawstarlight:fix/repl-doctest-new-require

Conversation

@impawstarlight

Copy link
Copy Markdown
Member

Resolves none.

Description

What is the purpose of this pull request?

This pull request:

  • Fixes precedence collision between the new keyword and injected require statement by wrapping the require statement in parentheses.

Related Issues

Does this pull request have any related issues?

None.

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.

No.

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

N/A.


@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: passed
  - 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
---
@impawstarlight
impawstarlight requested a review from a team July 18, 2026 12:50
@stdlib-bot stdlib-bot added Tools Issue or pull request related to project tooling. Needs Review A pull request which needs code review. labels Jul 18, 2026
@impawstarlight impawstarlight changed the title fix: fix dynamic require collision with new keyword fix: fix dynamic require collision with new keyword for repl doctest Jul 18, 2026
---
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: passed
  - 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
---
@impawstarlight

Copy link
Copy Markdown
Member Author

I see that a similar line is also present in @stdlib/repl/help/scripts/build.js that injects require(). I'm not sure when it is run but I've updated that as well.

@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
repl/help $\\color{green}95/95$
$\\color{green}+100.00\\%$
$\\color{green}7/7$
$\\color{green}+100.00\\%$
$\\color{green}1/1$
$\\color{green}+100.00\\%$
$\\color{green}95/95$
$\\color{green}+100.00\\%$

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

@Planeshifter Planeshifter changed the title fix: fix dynamic require collision with new keyword for repl doctest build: fix dynamic require collision with new keyword for repl doctest Jul 18, 2026

@Planeshifter Planeshifter 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 this and ensuring that we do not call require with new but the loaded constructor module!

@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Jul 18, 2026
@stdlib-bot

stdlib-bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

PR Commit Message

build: ensure correct operator precedence when using a dynamic `require` expression

PR-URL: https://github.com/stdlib-js/stdlib/pull/13537

Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
Reviewed-by: Athan Reines <kgryte@gmail.com>

Please review the above commit message and make any necessary adjustments.

@kgryte kgryte changed the title build: fix dynamic require collision with new keyword for repl doctest build: ensure correct operator precedence when using a dynamic require expression Jul 18, 2026
@kgryte
kgryte merged commit 7d78500 into stdlib-js:develop Jul 18, 2026
33 checks passed
@impawstarlight
impawstarlight deleted the fix/repl-doctest-new-require branch July 18, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: 5 Tools Issue or pull request related to project tooling.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants