Skip to content

fix(util): implement native inherits - #3892

Merged
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-util-inherits-debuglog
Jun 1, 2026
Merged

proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-util-inherits-debuglog

Conversation

@andrewtdiz

Copy link
Copy Markdown
Contributor

Summary

  • Wire util.inherits through native module dispatch and direct native-codegen lowering.
  • Implement runtime prototype chaining, ctor.super_, and synthetic function-class parent registration so direct node:util imports behave like Node.
  • Preserve closure dynamic-property descriptor attributes, including the non-enumerable util.debuglog() logger name property.

Issue Cluster

Closes #2673.
Closes #3885.
Refs #2514.

These issues share the node:util native export path and closure/function descriptor behavior, so batching them keeps the runtime and parity coverage coherent.

Tests Added

  • test-parity/node-suite/util/inherits/basic.ts
  • test-parity/node-suite/util/inherits/validation.ts
  • Extended test-parity/node-suite/util/debuglog/basic.ts for the logger name descriptor.

Verification

  • npx -y node@25.9.0 --experimental-strip-types test-parity/node-suite/util/inherits/basic.ts
  • npx -y node@25.9.0 --experimental-strip-types test-parity/node-suite/util/inherits/validation.ts
  • npx -y node@25.9.0 --experimental-strip-types test-parity/node-suite/util/debuglog/basic.ts
  • PATH=/tmp/perry-node25-bin:$PATH ./run_parity_tests.sh --suite node-suite --module util --filter util/inherits
  • PATH=/tmp/perry-node25-bin:$PATH ./run_parity_tests.sh --suite node-suite --module util --filter util/debuglog/basic
  • PATH=/tmp/perry-node25-bin:$PATH ./run_parity_tests.sh --suite node-suite --module util
  • cargo check -p perry-runtime --quiet
  • cargo fmt --all -- --check
  • git diff --check
  • ./scripts/check_file_size.sh
  • jq empty test-parity/known_failures.json
  • cargo build --release --quiet -p perry -p perry-runtime -p perry-stdlib

Known Limitations / Non-Goals

  • This does not change node:stream inheritance or any node:stream compose behavior.
  • This does not attempt a broader cleanup of existing Rust warnings emitted by the checked crates.

Wire util.inherits through the native dispatch and direct codegen paths so it sets the prototype chain, exposes non-enumerable super_, and preserves instanceof behavior for synthetic function classes.

Also preserve closure property attributes for dynamic function properties and keep util.debuglog logger.name non-enumerable.

Closes PerryTS#2673. Closes PerryTS#3885. Refs PerryTS#2514.
@proggeramlug
proggeramlug merged commit 6d9a49a into PerryTS:main Jun 1, 2026
11 checks passed
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.

node:util: debuglog loggers expose an extra enumerable name property node:util: implement util.inherits in the native dispatch path

2 participants