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

%TypedArray%.from reads its source before checking that this is a constructor

Aperta
#1,767 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c, javascript
Ambito
compilers

Direzione di ricerca

Start by locating QuickJS-ng’s implementation of %TypedArray%.from and any existing tests for typed-array built-ins; the issue does not name files or test paths. Compare the operation order with the spec steps cited in the report. Done when an invalid this value throws TypeError before accessing the source iterator or length, with regression tests covering both cases.

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

Descrizione

Reproduction
Uint8Array.from.call({}, { get [Symbol.iterator]() { throw 0; } });
Expected

A TypeError, because {} is not a constructor. The getter is never called.

V8 (15.6.20):

$ v8 -e 'Uint8Array.from.call({}, { get [Symbol.iterator]() { throw 0; } });'
TypeError: #<Object> is not a constructor
Actual (QuickJS-ng)
$ qjs -e 'Uint8Array.from.call({}, { get [Symbol.iterator]() { throw 0; } });'
0
Spec

The first steps of %TypedArray%.from are "Let ctor be the this value. If IsConstructor(ctor) is false, throw a TypeError exception." Only after that does it look at mapper and call GetMethod(source, %Symbol.iterator%).

QuickJS-ng checks the constructor only when it creates the result, after the whole source has been consumed. So the iterator is run to completion first, and the array-like length is read first, before the TypeError:

$ qjs -e 'Uint8Array.from.call({}, (function* () { print("next"); yield 1; })());'
next
TypeError: not a constructor      # V8: TypeError only, "next" is never printed
$ qjs -e 'Uint8Array.from.call({}, { get length() { throw 0; } });'
0                                 # V8: TypeError: #<Object> is not a constructor

%TypedArray%.of is unaffected: it has no source to read before the check.

JavaScriptCore, SpiderMonkey, GraalJS, XS and V8 all throw the TypeError without calling the getter.

Versions
  • QuickJS-ng: 0.17.0
  • V8: 15.6.20
Lingua principale
C
Stelle
3.9k
Fork
389
Merge medio
4g 1h
PR unite (30g)
24

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

Tutte le issue di quickjs-ng/quickjs

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.