Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

structuralIdentity merges distinct RegExp values with reference-valued lastIndex

Ouverte
#2,192 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
22/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
javascript, typescript

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
TypeScript
Étoiles
3.9k
Forks
277
Merge moyen
22 h 54 min
PR mergées (30 j)
236

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de TanStack/db

Toutes les issues de TanStack/db

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.