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

String.prototype.matchAll reads %Symbol.matchAll% before IsRegExp, and match/matchAll/search re-read %Symbol.match%

Aperta
#1,796 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
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c, javascript
Ambito
backend

Direzione di ricerca

Start by tracing QuickJS-ng’s implementations of String.prototype.matchAll, match, and search, then inspect how they create a RegExp and where the observable symbol-property reads occur. Compare that order with the specification steps cited in the issue and run the reproduction against qjs; done means the logged reads match the expected output for all three methods.

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

Descrizione

Reproduction
// sample.js
var log = [];
function logged(target) {
  return new Proxy(target, {
    get(t, k) {
      if ([Symbol.match, Symbol.matchAll, Symbol.search].includes(k)) log.push("get " + k.description);
      return Reflect.get(t, k);
    },
  });
}
try { "".matchAll(logged({ [Symbol.match]: true, flags: "" })); } catch (e) { log.push(e.name); }
print("matchAll: " + log.join(", "));
log = [];
"".match(logged({}));
print("match: " + log.join(", "));
log = [];
"".search(logged({}));
print("search: " + log.join(", "));
Expected

V8 (15.6.20):

$ v8 sample.js
matchAll: get Symbol.match, TypeError
match: get Symbol.match
search: get Symbol.search
Actual (QuickJS-ng)
$ qjs sample.js
matchAll: get Symbol.matchAll, get Symbol.match, TypeError
match: get Symbol.match, get Symbol.match
search: get Symbol.search, get Symbol.match
Spec

String.prototype.matchAll first calls IsRegExp and checks flags for "g" (steps 3.a ~ 3.b), and only then gets %Symbol.matchAll% (step 3.c). QuickJS-ng gets %Symbol.matchAll% first.

When the argument has no matcher, match, matchAll, and search create the RegExp with RegExpCreate (step 5), which does not call IsRegExp. QuickJS-ng calls the RegExp constructor instead, whose step 1 reads %Symbol.match% again.

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.