[Bug] Compiler drops unary-plus numeric defaults

未关闭
#116 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@BichengWang 已经在做这个了。

开始于 2026年11月29日。

  • #117 来自 @BichengWang —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
领域
compilers

调研方向

Start by locating extractNumberValue() and tracing how it handles numeric literal signs during compilation; the issue says unary minus works while unary plus is omitted. Reproduce with the YAML snippet through @agentscript/parser, Dialect().parse(), and compile(), then check the three defaults in output.agent_version.state_variables. Done means unary-plus values are preserved in object properties, list elements, and configuration parameter extraction; linked PR #117 is already open.

由索引模型根据 Issue 内容生成。

描述

Description

The compiler silently omits numeric defaults with an explicit unary +. In nested objects it drops the property; in lists it drops the element and changes the remaining positions.

Steps to Reproduce

  1. Check out salesforce/agentscript main at c3f8249a99ec908a6b61d1125945691447267e90 and build the workspace dependencies.
  2. Parse the snippet below with @agentscript/parser, then pass the mapping to new Dialect().parse(mapping, AgentforceSchema) and compile the resulting value with compile().
  3. Inspect output.agent_version.state_variables.

Expected Behavior

The defaults are 1, {"positive": 1, "negative": -2}, and [1, -2, 0] respectively. A unary plus on a numeric literal should preserve its value.

Actual Behavior

count has no default, payload.default is {"negative": -2}, and values.default is [-2]. Parser/schema diagnostics, the default Agentforce lint rules, and compiler diagnostics are all empty for this example.

Environment

  • Node.js: 22.20.0
  • pnpm: 10.34.6
  • OS: macOS, arm64
  • Compiler: workspace version 3.38.4 at the commit above

Minimal Reproduction

config:
    developer_name: "SignedDefaults"
variables:
    count: mutable number = +1
    payload: mutable object = {"positive": +1, "negative": -2}
    values: mutable list[number] = [+1, -2, +0]
start_agent main:
    description: "Entry point"
    reasoning:
        instructions: ->
            | Values: {[email protected]}, {[email protected]}, {[email protected]}

Additional Context

extractNumberValue() handles unary minus but not unary plus. The parser and type inference recognize both numeric signs. This also affects numeric extraction in configuration parameters; it is separate from the empty-object and None defects in #101 and #103.

主要语言
TypeScript
星标
279
派生
55
平均合并
1 天 12 小时
30 天内合并 PR
7

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

salesforce/agentscript 的其他 Issue

查看 salesforce/agentscript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。