Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

structuralIdentity merges distinct RegExp values with reference-valued lastIndex

オープン
#2,192 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
22/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript, typescript

調査の方向性

Start with packages/db-ivm/src/hashing/hash.ts, where structuralIdentity and equalHashValues treat RegExp lastIndex differently. Reproduce with the snippet in the issue, then add a reference-valued lastIndex witness to the structural-identity oracle and exercise the groupBy path. Done when the two values stay separate in groupBy and the existing hash tests still pass.

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

説明

Bug

D2 equality treats RegExp lastIndex as a header compared with ===, but structuralIdentity recursively encodes that header. Separate reference-valued headers with the same contents therefore produce one defined identity for unequal values.

import {
  equalHashValues,
  structuralIdentity,
} from './packages/db-ivm/src/hashing/hash.ts'

const a = /a/g
const b = /a/g
a.lastIndex = Object.freeze({ x: 1 })
b.lastIndex = Object.freeze({ x: 1 })
Object.freeze(a)
Object.freeze(b)

console.log(equalHashValues(a, b)) // false
console.log(structuralIdentity(a) === structuralIdentity(b)) // true

JavaScript permits assigning an object to lastIndex; TypeScript's RegExp declaration models only the usual numeric value. The witness remains after both values and headers are frozen. hash.ts explicitly allows any lastIndex value in the header.

Impact

groupBy uses the defined structural identity as a prefix key. A real D2 aggregate over the two values above reported one distinct contribution where D2 equality distinguishes two. The two values also have equal structural hash digests, so returning undefined from structuralIdentity alone does not establish a correct groupBy fallback.

Test gap and repair boundary

The structural-identity oracle currently generates only numeric lastIndex values. The hash-identity oracle also limits its RegExp grammar. Add reference-valued headers to an independent model and a direct helper witness, then exercise the receiving groupBy path. The production fix should preserve the law that a shared defined identity implies D2 equality and that D2-unequal contributions stay separate. This is a pre-existing defect found while reviewing PR #2153; that PR only repairs the oracle's nested-array normal form.

主要言語
TypeScript
スター
3.9k
フォーク
272
平均マージ
22時間 54分
マージ済み PR(30日)
236

環境構築

はじめの一歩

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

TanStack/db のほかの issue

TanStack/db の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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