[Bug] Compiler rewrites literal @variables text in expressions
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- compilers
调研方向
Start with the failing case in packages/compiler/test/expressions.test.ts and the compileExpression function it calls, paying attention to the final regex replacement that runs on serialized text. Compare that with how the AST compiler resolves member references, including inside function arguments, so that only real references are rewritten. Done when the new test passes with "@variables.missing" and no diagnostics, and existing reference expressions still resolve to the runtime namespaces.
由索引模型根据 Issue 内容生成。
描述
Description
compileExpression rewrites literal @variables.<name> text after serializing the AST. This changes string values and comparison operands, and can report an unknown-variable warning for text that is not a reference.
Steps to Reproduce
- Check out
mainatace15eband install/build the compiler dependencies. - Add this case to
packages/compiler/test/expressions.test.ts(the imports already exist there):
it('preserves reference-like text in a string', () => {
const ctx = new CompilerContext();
const expr = new StringLiteral('@variables.missing');
expect(compileExpression(expr, ctx)).toBe('"@variables.missing"');
expect(ctx.diagnostics).toEqual([]);
});
- Run
pnpm --filter @agentscript/compiler test test/expressions.test.ts.
Expected Behavior
The compiled expression is "@variables.missing", with no diagnostics. Only actual reference expressions should resolve to runtime namespaces.
Actual Behavior
The compiled expression is "state.missing", with warning Variable 'missing' not found in known variables, defaulting to state namespace.
For a parsed expression such as @variables.x == "@variables.x", the compiler similarly emits state.x == "state.x" instead of state.x == "@variables.x". Function arguments and plain template text are affected too.
Environment
- Node.js: 22.20.0
- pnpm: 10.34.6
- OS: macOS, arm64
- Package:
@agentscript/compiler3.26.1, source commitace15eb
Minimal Reproduction
The isolated test above reproduces the defect without a runtime service or credentials.
Additional Context
The final regular-expression replacement in compileExpression operates on serialized text, including quoted literals. The AST compiler already resolves member references recursively, including references inside function arguments.
- 主要语言
- TypeScript
- 星标
- 272
- 派生
- 56
- 平均合并
- 12 小时 18 分钟
- 30 天内合并 PR
- 5
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
salesforce/agentscript 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 61/100
salesforce/agentscript#85 ·
-
README Quick Start fails on macOS: Node 26 incompatibility and missing tree-sitter CLI prerequisite可能重新可做 @dsorajisto 于 156 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 半天 新手友好度 75/100
salesforce/agentscript#33 · 2 条评论 ·
-
[Bug] List type parameters silently accept non-type expressions可能已有人在做 @BichengWang 于 6 天前认领。 未关闭
难度 3/5 半天 新手友好度 55/100
salesforce/agentscript#91 ·
-
难度 4/5 3-5 天 新手友好度 52/100
salesforce/agentscript#73 ·
-
[bug]: @sf-agentscript/[email protected] (latest) still unusable — dist/ compiled against a newer @sf-agentscript/language than package.json pins (missing export `nullLiteralValidationPass`)可能已有人在做 @srikolagani 于 40 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 55/100
salesforce/agentscript#71 · 1 条评论 ·
查看 salesforce/agentscript 的全部 Issue
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 75/100
siyuan-note/siyuan#20629 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Volume eject does not refuse system, root or /home mounts可能已有人在做 @bernardopg 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
spacedriveapp/spacedrive#3159 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
melgarafael/DeskcommCRM#3000 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
callstackincubator/simlock#639 ·
维护者通常 1 天内回复