Skip to content

fix(node:buffer): handle Buffer.from object sources#2298

Merged
proggeramlug merged 2 commits into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-buffer-from-arraylike-coercions
May 28, 2026
Merged

fix(node:buffer): handle Buffer.from object sources#2298
proggeramlug merged 2 commits into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-buffer-from-arraylike-coercions

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

@andrewtdiz andrewtdiz commented May 28, 2026

Part of #793.

Summary:

  • detect plain object array-like inputs in Buffer.from before the ArrayHeader fallback
  • require a numeric length, return empty for non-number/non-positive lengths, and truncate fractional lengths
  • honor custom valueOf() string/object results and string-returning Symbol.toPrimitive sources
  • read indexed properties through object lookup and share byte coercion with array sources

Verification:

  • DeepWiki: reference/deepwiki/nodejs-node-buffer-from-arraylike-coercions-2026-05-28.md
  • DeepWiki: reference/deepwiki/nodejs-node-buffer-from-object-primitives-2026-05-28.md
  • Baseline exact node-suite/buffer/from/arraylike-coercions: FAIL, report test-parity/reports/parity_report_20260528_125501.json
  • Final exact node-suite/buffer/from/arraylike-coercions: PASS, report test-parity/reports/parity_report_20260528_125818.json
  • Baseline exact node-suite/buffer/from/valueof-symbol-to-primitive: FAIL, report test-parity/reports/parity_report_20260528_130501.json
  • Final exact node-suite/buffer/from/valueof-symbol-to-primitive: PASS, report test-parity/reports/parity_report_20260528_130903.json
  • Full node-suite/buffer/from: 15 PASS / 1 parity FAIL, report test-parity/reports/parity_report_20260528_130955.json; only primitive input validation remains red and is covered by fix(node:buffer): reject primitive from inputs #2287
  • Full node-suite/buffer: 105 PASS / 10 parity FAIL / 1 compile FAIL, report test-parity/reports/parity_report_20260528_131022.json; targets green
  • cargo check -p perry-runtime -p perry-stdlib -p perry-codegen: PASS with existing warnings
  • cargo fmt --check: PASS
  • jq empty test-parity/known_failures.json: PASS
  • git diff --check: PASS

Non-goals:

@andrewtdiz andrewtdiz changed the title fix(node:buffer): handle array-like Buffer.from objects fix(node:buffer): handle Buffer.from object sources May 28, 2026
@proggeramlug proggeramlug merged commit b591617 into PerryTS:main May 28, 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.

2 participants