`{ ..."ab" }` is `{}`; a throw in a `for await` body does not wait for the iterator's return()

Aperta
#611 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 5 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c, javascript
Ambito
backend, compilers

Direzione di ricerca

Start by reading the object spread path and JS_CopyDataProperties, then trace how the source is converted before its properties are copied. For the for await case, follow AsyncIteratorClose and its handling of throw completions. Use the two reproductions in the issue to check both behaviors; done means string properties are copied and iterator cleanup finishes before the catch runs.

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

Descrizione

1. Object spread of a string primitive copies nothing.

console.log(JSON.stringify({ ..."ab" }));                  // {"0":"a","1":"b"}
console.log(JSON.stringify({ ...new String("ab") }));      // {"0":"a","1":"b"}

./qjs t.js prints {} for the first line; the second is correct, and so are Object.assign({}, "ab") and const {...r} = "ab". JS_CopyDataProperties returns early when the source is not an object, and the object-literal spread path doesn't convert the source with ToObject first.

2. A throw in a for await body doesn't await return().

const log = [];
async function* g() { try { yield 1; } finally { log.push("finally"); } }
(async () => {
  try { for await (const v of g()) throw "t"; } catch (e) { log.push("catch"); }
  console.log(log.join(" "));   // expected: finally catch
})();

Actual: catch (the finally runs later). With break instead of throw master is correct; the 2026-06-04 release gets both wrong. AsyncIteratorClose awaits the result of return() even when the completion is a throw.

Versions: master e5ac135 (2026-11-09) and release 2026-06-04, Linux x86-64.

Credit: https://ucsbplse.github.io/

Lingua principale
C
Stelle
11.1k
Fork
1.2k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 bellard/quickjs

Tutte le issue di bellard/quickjs

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.