Skip to content

fix: Hermes withPrefixKey crash and Turbopack static this in scope.module - #1674

Merged
ssalbdivad merged 1 commit into
mainfrom
fix/hermes-turbopack
Oct 1, 2026
Merged

ssalbdivad merged 1 commit into
mainfrom
fix/hermes-turbopack

Conversation

@ssalbdivad

Copy link
Copy Markdown
Member

Closes #1645
Closes #1643

  • Disjoint.withPrefixKey now rebuilds a Disjoint when map returns a plain Array, the same Hermes workaround invert already had (Unable to use ArkType with Expo #1027). A test simulates Hermes by overriding Symbol.species.
  • InternalScope.module calls InternalScope.scope instead of this.scope, which Turbopack can compile to an undefined binding.

Lint, build and testRepoWithVersionsAndBenches pass locally.

🤖 Generated with Claude Code

…module

Hermes doesn't honor Symbol.species, so Array.prototype.map on a Disjoint
returns a plain Array. invert() already rebuilt a Disjoint in that case
(#1027); withPrefixKey() just cast the result, so unions of objects
disjoint at a key crashed on Expo/React Native when a later Disjoint
method was called on it. It now uses the same workaround (#1645).

InternalScope.module referenced `this` inside a static arrow field,
which Turbopack's transform can compile to an undefined module-level
binding. It now calls InternalScope.scope directly (#1643).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — verified both Hermes/Turbopack compatibility fixes and the accompanying regression test.

  • Disjoint.withPrefixKey Hermes workaround — rebuilds a Disjoint via new Disjoint(...result) when map returns a plain Array, mirroring the existing invert guard. The removed as Disjoint cast is correctly replaced by a truthful as DisjointEntry[]; the instanceof check then narrows back to Disjoint. On standard engines the behavior is unchanged.
  • InternalScope.module static this removal — this.scope is now InternalScope.scope. The old this resolved identically for every live caller (InternalScope.module, the re-exported Scope alias in ark/type/keywords/*, and the detached $.constructor.module attached to Parser), so this is behavior-preserving while removing the Turbopack static-binding hazard.
  • Regression test — overrides Symbol.species to Array and asserts both withPrefixKey(...) and invert() return Disjoint instances. I reverted the withPrefixKey guard locally and confirmed the test fails (false !== true at union.test.ts:112), so it pins the actual bug rather than passing vacuously.

Other Disjoint methods that use map (describeReasons) only call .join, so they don't depend on subclass preservation and need no equivalent guard — coverage here is complete.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@ssalbdivad
ssalbdivad merged commit 066f4f2 into main Oct 1, 2026
7 checks passed
@ssalbdivad
ssalbdivad deleted the fix/hermes-turbopack branch October 1, 2026 20:09
@github-project-automation github-project-automation Bot moved this from To do to Done (merged or closed) in arktypeio Oct 1, 2026
@ssalbdivad ssalbdivad mentioned this pull request Oct 1, 2026
4 tasks done
ssalbdivad added a commit that referenced this pull request Oct 1, 2026
Bumps all publishable packages and documents the changes merged since 2.2.6:

- fix `this[]` in self-referential object types (#1618, fixes #1406,
  @yharaskrik)
- parse string.date.epoch.parse input as milliseconds (#1669, @breken-ai)
- keep uppercase UUIDs valid in string.uuid JSON Schema (#1670,
  @breken-ai)
- render nested bigints correctly in error messages (#1626, fixes #1477,
  @chatman-media)
- release unused parse ids from the global registry (#1673, fixes #1584
  for equivalent types, @isaacwasserman)
- fix crashes on Hermes and Turbopack (#1674, fixes #1645 and #1643)

#1590 only adds tests, so it has no changelog entry.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done (merged or closed)

1 participant