Repository navigation
fix(codemode): make Buffer map, filter, slice and subarray return a Buffer - #64933
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
The change looks sound. I copied the new test into the base checkout and it fails there; with this PR it passes. The full packages/codemode suite (1786/1786) and tsc --noEmit also pass, and the prelude-bytecode test confirms the regenerated bytecode.json matches the source.
Putting derive on Bytes, with an override in BufferObj, gives one hook for both the native slice/subarray and the prelude's map/filter. Subclasses of Uint8Array still get a plain Uint8Array back, as before, so nothing regresses.
Public API: unchanged (this is internal Code Mode interpreter behaviour only).
No concerns.
jlongster
added a commit
to anomalyco/psychoscript
that referenced
this pull request
Nov 19, 2026
…enCode Ports anomalyco/opencode#64933, #64931, #64935 and #64938, which landed in OpenCode's language after the move. User decisions: - psychoscript holds only the language, nothing tool-specific
1 task
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In Code Mode, the
Uint8Arraymethods aBufferinherits made a plainUint8Array, so the result lost Buffer's UTF-8toString. Real Bun uses species semantics and returns a Buffer.Bytesgets aderivemethod, whichBufferObjoverrides to make a Buffer.Uint8Array.prototype.slice/subarrayand the prelude'smap/filter(through a new prelude-only$DerivedByteshelper) now build their result with it. PlainUint8Arrayresults don't change. I checked every case against Bun:reverse,sortandfillalready returned the receiver, and Bun'stoSorted,toReversedandwithreturnUint8Array(Code Mode doesn't implement them on Uint8Array). Updatedinterpreter-support.mdand regenerated the prelude bytecode.Testing
packages/codemode/test/buffer.test.ts. It fails without the fix.bun testinpackages/codemode: 1785/1786 pass. The one failure, "reporting many unhandled rejections still times out", hit a timeout while the shared machine was loaded and passes when run alone.bun typecheck(codemode) andbun run check(root) both pass.Visual