[Bug] List type parameters silently accept non-type expressions

Aberta
#91 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@BichengWang já está trabalhando nisso.

Desde 10/10/2026.

  • #92 de @BichengWang — aberto

Avaliação

Dificuldade
3/5
Tempo estimado
Meio dia
Facilidade para iniciantes
55/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
typescript
Domínio
tooling

Direção de pesquisa

Start in the TypedMapParser.validateSubscriptType function, which currently handles only identifier and nested-subscript arguments, and see how it dispatches on argument shape. Add an Error diagnostic of kind invalid-type-parameter for literal, reference and expression arguments inside list brackets, pointing at the argument. Done when the five declarations in the reproduction yield Error diagnostics and the real-schema regression tests pass, while supported primitives and the unknown-type and nested-list-type controls still behave as before.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Description

List declarations accept literals and other expressions as their element type without an error. The documented list syntax requires a supported type, such as list[string], but TypedMapParser.validateSubscriptType only handles identifier and nested-subscript arguments. Other argument shapes fall through validation.

Steps to Reproduce

  1. Use the source checkout at 16396089a4264b544d40d4aaf83c1f8aa981760c with the standard AgentScript schema and default lint rules.
  2. Parse each declaration in the reproduction below.
  3. Inspect the parse and lint diagnostics.

Expected Behavior

Each non-type argument produces an Error diagnostic pointing to the argument inside the brackets. Supported primitive identifiers remain accepted.

Actual Behavior

All five declarations parse without syntax errors and receive no type Error. The default lint engine reports only an unused-variable warning for an isolated declaration. Controls correctly reject list[missing] as unknown-type and list[list[string]] as nested-list-type.

Environment

  • Node.js: 22.20.0
  • pnpm: 10.28.0
  • OS: macOS 27.0.1, arm64
  • Package: source build of @agentscript/language 3.2.3 and @agentscript/agentscript-dialect 3.4.0

Minimal Reproduction

variables:
    number_parameter: mutable list[1]
    boolean_parameter: mutable list[True]
    string_parameter: mutable list["string"]
    reference_parameter: mutable list[@variables.other]
    expression_parameter: mutable list[string + number]

Additional Context

Real-schema regression tests for these five forms fail against unchanged code because the Error diagnostic array is empty. All 12 supported element types and the two negative controls pass in the same run: 5 failed, 14 passed. The change can reuse invalid-type-parameter for the previously unhandled argument shapes.

Linguagem predominante
TypeScript
Estrelas
274
Forks
56
Merge médio
12h 18min
PRs com merge (30d)
5

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de salesforce/agentscript

Todas as issues de salesforce/agentscript

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.