Completion inside a list literal ignores the element type

Aperta
#9,212 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
ocaml
Ambito
devtools

Direzione di ricerca

Start by comparing the completion context path for array literals with the Type_utils.extract_type behavior described for list<'a>. The issue names no test file, and notes there are no existing completion tests for list literals, so first locate the completion tests and add coverage for typed list elements, including partially typed elements and an empty list. Done means completions use the list element type as they do for arrays.

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

Descrizione

What is broken

Completion inside a list{…} literal doesn't use the list's element type, while the same position in an array literal does:

type kind = First | Second

let arr: array<kind> = [First, ]
//                            ^com First, Second
let ys: list<kind> = list{First, }
//                              ^com nothing
let zs: list<kind> = list{First, Se}
//                                 ^com only `module Set`
let f = (x: list<kind>) => x
let _ = f(list{})
//             ^com nothing

The completion log shows why: for the array the context path is array<Type[kind]> and then Type[kind], but for the list it is Type[list], so the element type kind is lost. A partly typed element then falls back to untyped completion (module Set for Se).

Checked on master ac7357822e. There are no completion tests for list literals, which is why it went unnoticed. It came up while fixing array spreads in #9199 (#9183), which leaves lists alone for this reason.

Possible cause (speculation only)

Type_utils.extract_type has no case for list<'a>, and looking up the built-in list type fails, so there is no element type to complete from.

A related limit: list{...xs, } with a trailing hole is parsed as the plain expression xs, because a spread in tail position is a :: chain, so no completion position remains there.

🤖 Generated with Claude Code

Lingua principale
OCaml
Stelle
7.5k
Fork
484
Merge medio
17h 9m
PR unite (30g)
264

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 rescript-lang/rescript

Tutte le issue di rescript-lang/rescript

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.