Valid legacy regex fragments are rejected before native compilation

Aperta
#3,035 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@MathurAditya724 ci sta già lavorando.

Dal 5/11/2026.

  • #3041 di @MathurAditya724 — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
javascript, node.js, typescript

Direzione di ricerca

Start by saving the reduced example as fragment.mjs and comparing scriptc's diagnostic with Node 24.22.1. Trace the regex literal diagnostic path and the TypeScript diagnostic boundary mentioned in the issue; cover fragment composition, legacy escapes, capture references, replacements, and invalid Unicode patterns. Compare native output with Node, including sanitized execution; done means valid legacy fragments compile while invalid u and v patterns still reject. An open linked pull request (#3041) is already addressing this issue.

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

Descrizione

We are compiling the full Sentry CLI with scriptc, including its existing dependencies. highlight.js builds a Perl grammar by taking the source of a legacy regular-expression fragment and inserting it into a larger pattern. The fragment is valid JavaScript, but the build stops with SC0001 before it reaches the native regex runtime.

A reduced example is:

console.log(new RegExp("(a)" + /\1/.source).test("aa"));

Save this as fragment.mjs. Node 24.22.1 prints true. Building it with scriptc built from current main reports that the backreference refers to a group that does not exist (TypeScript TS1534). The related literal /(a)\2/ reaches TS1533 instead.

These non-Unicode literals have defined legacy semantics. Their source can also be reused in a pattern with enough capture groups, as in the example. The standalone literal and the final constructed pattern are different expressions and should each keep their JavaScript behavior.

Expected behavior is to compile valid legacy fragments and match Node. Regexes with u or v must still reject invalid backreferences. This should not be fixed by discarding all regex grammar diagnostics or changing the fragment's source text.

Regression coverage should include fragment composition, standalone octal and identity escapes, real capture references and replacement, invalid Unicode patterns, and the existing TypeScript diagnostic boundary. Native output needs to be compared with Node, including sanitized execution.

This removes one observed blocker from the CLI bundle; it does not establish that the whole CLI compiles. I rechecked open issues and PRs before filing this. The RegExp call handling in #2928 addresses a different lowering path, rather than these literal diagnostics.

Lingua principale
TypeScript
Stelle
6.4k
Fork
204
Merge medio
7h 45m
PR unite (30g)
845

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.