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

Generic arrow declared inside a function is refused even when it captures nothing (SC1090)

Chiusa
#1,624 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Una pull request collegata è già stata integrata.

  • #1627 di @ctate — integrata

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
compilers

Direzione di ricerca

Start by tracing where the compiler reports SC1090 for generic arrow or function-expression bindings declared inside functions, then inspect how it handles equivalent module-scope bindings. The example in the issue shows the expected Node output and that put captures no enclosing values. Done means the example compiles and prints 1,2,3 a,b without SC1090 or SC2004.

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

Descrizione

A generic arrow function declared inside a function is refused, even when it captures nothing from the enclosing frame.

function f(): void {
  const put = <T>(xs: T[], x: T): T[] => [...xs, x];
  console.log(put([1, 2], 3).join(","), put(["a"], "b").join(","));
}
f();

Expected (Node 24.22.0):

$ node generic.ts
1,2,3 a,b

Actual, with 0.4.0 and with main at 0bb7411:

$ scriptc build generic.ts
generic.ts:2:15 - error SC1090: generic arrow/function-expression bindings declared inside functions (the compiled instantiations of 'put' are module functions and cannot capture the enclosing frame — declare the binding at module scope) are not supported yet
generic.ts:3:15 - error SC2004: uses of 'put' inherit the blocker on its declaration

put refers only to its own parameters, so its instantiations could be module functions as they are for a module-scope binding.

Lingua principale
TypeScript
Stelle
6.2k
Fork
183
Merge medio
3h 22m
PR unite (30g)
868

Preparare l'ambiente

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 vercel-labs/scriptc

Tutte le issue di vercel-labs/scriptc

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.