Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug] Compiler rewrites literal @variables text in expressions

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

@BichengWang 已经在做这个了。

开始于 2026年10月15日。

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

评估

难度
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

  1. Check out main at ace15eb and install/build the compiler dependencies.
  2. 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([]);
});
  1. 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/compiler 3.26.1, source commit ace15eb

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

环境准备

在 Codespaces 中打开

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

从这里开始

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

salesforce/agentscript 的其他 Issue

查看 salesforce/agentscript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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