You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Compiler loses __proto__ keys in object variable defaults #102
A quoted __proto__ dictionary key disappears from a mutable object default during compilation. With an object value, the compiler changes the default object's prototype instead of creating an own property. No parser, schema, lint, or compiler diagnostic is returned.
Steps to Reproduce
Check out salesforce/agentscript at ace15eb2dc75564fd9e214385ac045c539056770 (current main).
Parse the source below with @agentscript/parser, convert it with new Dialect().parse(mappingNode, AgentforceSchema), and run the Agentforce defaultRules() through LintEngine with agentforceSchemaContext.
Pass the parsed value to compile() and inspect the payload entry in output.agent_version.state_variables, before any camelCase conversion.
Expected Behavior
The default has an own __proto__ property and serializes as:
{"__proto__":{"marker":"kept"},"normal":{"n":1}}
Actual Behavior
The default serializes as:
{"normal":{"n":1}}
Object.hasOwn(payload.default, '__proto__') is false, while Object.getPrototypeOf(payload.default).marker is "kept". A scalar value ("__proto__": "kept") is also lost. A "constructor": {"marker": "kept"} control retains its own key and value.
Environment
Node.js: 22.20.0
pnpm: 10.34.6
OS: macOS 27.0.1, arm64
Package: @agentscript/compiler, source checkout at the commit above
extractDictExpression() in packages/compiler/src/ast-helpers.ts assigns entries with result[key] = value on an ordinary object. For __proto__, that invokes the inherited setter. This is a different path from #88/#89: the loss is already present in the snake_case output of compile(), without calling snakeKeysToCamel. The dictionaries here are nonempty, so this also differs from #101's empty-dictionary loss.
Reproduced offline with assertions on object/scalar __proto__ values and the constructor control. The existing compiler suite passed (1,113 passed, 3 skipped), and the required TypeScript package builds passed. The standard dependency build was blocked by the missing tree-sitter CLI; no native-parser or full monorepo checks were run. No fix is included.
Activity