microsoft / microsoft/TypeScript

Poor error recovery when `enum` is used as a parameter name

Aperta
#33,931 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug Domain: Error Messages
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

TypeScript Version: 3.6.2

Search Terms: expression expected reserved word

Code

function converter<Enum>(values: string[], enums: Enum[]): Map<Enum, string> {
	return new Map<Enum, string>(
		enums.map((enum: Enum, index: number) => [ enum, values[index] ])
	);
}

Expected behavior:
After some confusion why this displays so many red curlies, the error should make it clear to me that the reserved word enum is accidentaly being used as an argument name. An error is given on enum saying something along the lines of You cannot use enum as a variable/argument because it is a reserved word.

Actual behavior:
After a LOT of confusion, one realizes that the reserved word enum is accidentally being used as an argument name. An error is given on several parts in the above code, where the most helpful one is Expression expected (ts1109), which is just unnecesarily confusing.

Playground Link

Related Issues:
None that seem related.

Guida per i contributori

Apri la guida per i contributori

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.

Direzione di ricerca

Riproduci la diagnostica con il codice fornito nel TypeScript 3.6.2 Playground, quindi confronta gli errori del parser relativi al nome del parametro enum. Migliora l’errore segnalato in modo che identifichi l’uso improprio di una parola riservata senza produrre diagnostica a cascata confusa, quindi verifica il risultato con lo stesso esempio.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.