Valid legacy regex fragments are rejected before native compilation

クローズ
#3,035 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

関連するプルリクエストがすでにマージされています。

  • #3041 @MathurAditya724 による — マージされずにクローズ
  • #3112 @ctate による — マージ済み

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
javascript, node.js, typescript

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
6.5k
フォーク
212
平均マージ
13時間 2分
マージ済み PR(30日)
798

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

vercel-labs/scriptc のほかの issue

vercel-labs/scriptc の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。