Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Bug] Compiler rewrites literal @variables text in expressions

Aperta
#96 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@BichengWang ci sta già lavorando.

Dal 15/10/2026.

  • #97 di @BichengWang — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
compilers

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
272
Fork
56
Merge medio
12h 18m
PR unite (30g)
5

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di salesforce/agentscript

Tutte le issue di salesforce/agentscript

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.