Skip to content

fix(node): fill constants tail (constants/zlib Zstd) + util.types predicate tail#3702

Merged
proggeramlug merged 3 commits into
mainfrom
fix-constants-tail-3683-3677-3678
May 31, 2026
Merged

fix(node): fill constants tail (constants/zlib Zstd) + util.types predicate tail#3702
proggeramlug merged 3 commits into
mainfrom
fix-constants-tail-3683-3677-3678

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

Closes #3683
Closes #3677
Closes #3678

Implementation

#3683 — node:constants tail

Added the POSIX file-mode/open flags, libuv flags, and default-cipher metadata Node exposes but Perry resolved to undefined:

  • libuv: UV_DIRENT_* (0–7), UV_FS_SYMLINK_DIR/JUNCTION, UV_FS_COPYFILE_EXCL/FICLONE/FICLONE_FORCE
  • POSIX file-type masks: S_IFMT/S_IFREG/S_IFDIR/S_IFCHR/S_IFBLK/S_IFIFO/S_IFLNK/S_IFSOCK
  • open() flags: O_DIRECTORY/O_NOCTTY/O_NONBLOCK/O_SYNC/O_DSYNC/O_SYMLINK
  • defaultCoreCipherList (string)

Wired into both the value-read dispatch (node:constants and fs.constants) and the Object.keys enumerable-keys list. O_* / S_IF* use libc:: on Unix for host-accurate values (e.g. O_DIRECTORY differs Linux vs macOS); literal fallbacks for non-unix.

#3677 — node:zlib Zstd enumeration

Object.keys(zlib.constants) returned 0 keys; it now enumerates the full 170-key Z_*/BROTLI_*/ZSTD_* set Node exposes (63 of them ZSTD*), in Node's insertion order. Added the previously-missing Brotli decoder result/error codes and the ZSTD_error_* codes to the value-read dispatch so every enumerated key reads its backing value (no enumerate-but-undefined lie).

#3678 — node:util/types predicate tail

Added the predicates Perry can correctly back: isDataView, isFloat16Array, isWeakMap, isWeakSet, isExternal. Each is wired through the runtime dispatch (util/util.types/util/types), the codegen call-lowering maps, the native table, runtime decls, callable-export value resolution (so typeof === "function"), and the API manifest.

Dropped (would lie about unimplemented features): isBigIntObject / isSymbolObject (Perry boxes only Number/String/Boolean), isArgumentsObject (no distinct arguments object — Perry uses arrays), isModuleNamespaceObject, isKeyObject, isCryptoKey (no backing KeyObject/CryptoKey value type). A false-always stub would return the wrong answer for Node's positive cases.

Also added the missing manifest rows for process.sourceMapsEnabled / setSourceMapsEnabled (native-table drift introduced by #3684) so the manifest-consistency check stays green.

Validation

  • Gap test test-files/test_gap_constants_tail_3683plus.ts is byte-identical to node --experimental-strip-types under the DEFAULT auto-optimize compile.
  • cargo test --release green for perry-runtime (930), perry-codegen (incl. manifest_consistency drift check), perry-api-manifest (18), perry-hir.
  • cargo fmt --all -- --check clean, ./scripts/check_file_size.sh exit 0.
  • API docs regenerated (./scripts/regen_api_docs.sh).
  • No new HIR variants.

Ralph Küpper added 3 commits May 31, 2026 14:03
…dicate tail

#3683 node:constants — add POSIX file-flag (S_IF*, O_DIRECTORY/O_NOCTTY/
O_NONBLOCK/O_SYNC/O_DSYNC/O_SYMLINK), libuv (UV_DIRENT_*, UV_FS_SYMLINK_*,
UV_FS_COPYFILE_*), and defaultCoreCipherList metadata to both the value-read
dispatch (constants + fs.constants) and the enumerable-keys list. O_* use
libc on Unix for host-accurate parity; S_IF* are POSIX-standard.

#3677 node:zlib — Object.keys(zlib.constants) now enumerates the full 170-key
Z_*/BROTLI_*/ZSTD_* set Node exposes (was 0). Added the missing Brotli decoder
result/error codes and the ZSTD_error_* codes to the value-read dispatch so
every enumerated key reads its backing value.

#3678 node:util/types — add the predicate tail Perry can correctly back:
isDataView, isFloat16Array, isWeakMap, isWeakSet, isExternal. Dropped
isBigIntObject/isSymbolObject (Perry boxes only Number/String/Boolean),
isArgumentsObject (no distinct arguments object), isModuleNamespaceObject,
isKeyObject, isCryptoKey (no backing value type) — a false-always stub would
lie about Node's positive cases.

Also adds the missing manifest rows for process.sourceMapsEnabled /
setSourceMapsEnabled (drift from #3684) so manifest-consistency stays green.
…83-3677-3678

# Conflicts:
#	docs/api/perry.d.ts
#	docs/src/api/reference.md
@proggeramlug proggeramlug merged commit 07e663b into main May 31, 2026
@proggeramlug proggeramlug deleted the fix-constants-tail-3683-3677-3678 branch May 31, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant