refactor(codemode): make the host boundary JSON.stringify plus a short table - #49128
Merged
Merged
Conversation
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.
The host boundary is
JSON.stringify, plus a short table for values that cannot be JSON but whose intent is clear.One walker replaces four conversion modes and a second copy of itself.
tool-runtime.tsnow deals only inJson: arguments arrive converted and results leave asJSON.parse(JSON.stringify(decoded)), so program values never enter it. The conversion sits in one place,Interpreter.tool, which bothtools.*calls andsearchgo through.ToolRuntimeErrormoves there fromdata.ts.The table
SetURLSearchParamsError{ name, message, ...own }JSON.stringify)Uint8Array__proto__keyRegExp"/src/flags"{}like JS{}like JSundefinedproperty in the resultnullInvalidDataValueTypeError: Converting circular structure to JSON.toJSONdecode → host value → lossy copydecode → JSON.stringify → JSON.parseMapstays{}for now; a smarter form is a follow-up.In-program
JSON.stringifykeeps JS behavior except for the Error form and a promise, which is aTypeErrorwith an await hint — it cannot await synchronously, and a silent{}there is the footgun the table exists to prevent.Also gone: the
toProgram(...)calls on literals, operator results, and template interpolations ininterpreter.ts— those values are already primitives. BigInt literals now fail with a plainTypeErrorat the literal.Files
Checks
bun run checkclean;bun test5125 pass / 0 fail; test262 report unchanged at 3858 pass / 426 known-gap.